public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gaius at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-108557-4-gBip4RPL19@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108557-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108557

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gaius at gcc dot gnu.org

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 54361
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54361&action=edit
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.

  parent reply	other threads:[~2023-01-27 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 10:20 [Bug modula2/108557] New: " marxin at gcc dot gnu.org
2023-01-26 13:17 ` [Bug modula2/108557] " gaius at gcc dot gnu.org
2023-01-27 16:24 ` gaius at gcc dot gnu.org [this message]
2023-01-27 22:24 ` gaius at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108557-4-gBip4RPL19@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).