From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 79CFA3858423; Fri, 27 Jan 2023 16:24:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79CFA3858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674836650; bh=dKWGpvAl6lmeXa3pw8tOF3JuXBAlCtSGvQ+BIW7szz8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uC4juRYlcguN0SKrjZgJvJdNs/w4snoX+2K/58IwjeGn8ybgYa3emGU2ZQXOIldy0 rK6nhdWyBcdBVIfNcs73nFK8ts9fLJnIDYIVn7YLZow/87NzouW8yGlNvALGDEnuEb SVXWtRKv490KAKPUPj+SNto6B7sx8vnr3/hTASyo= From: "gaius at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/108557] Stuck compilation for empty file Date: Fri, 27 Jan 2023 16:24:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: compile-time-hog X-Bugzilla-Severity: normal X-Bugzilla-Who: gaius at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108557 Gaius Mulley changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gaius at gcc dot gnu.org --- Comment #2 from Gaius Mulley --- Created attachment 54361 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54361&action=3Dedit Proposed fix I believe this fixes the bug. PR-108557 Stuck compilation for empty file Trying to compile an empty file causes cc1gm2 to hang. The bug was that M2LexBuf.mod called m2flex.GetToken after an eof token was seen which resulted in m2flex attempting to read from stdin. The bug fix detects eof per file and blocks a subsequent to m2flex.GetToken. gcc/m2/ChangeLog: * gm2-compiler/M2Comp.mod: Import MetaString0. (ExamineCompilationUnit): New variable Message. Create and format error string. * gm2-compiler/M2LexBuf.mod: New variable SeenEof. (GetNonEofToken): New procedure. (Init): Set SeenEof to FALSE. (GetToken): Use GetNonEofToken instead of calls to m2flex.GetToken and GetToken. (AddTok): Detect eoftok and set SeenEof. gcc/testsuite/ChangeLog: * gm2/pim/fail/empty.mod: New test.=