public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Neil Booth <neil@daikokuya.demon.co.uk> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: preprocessor/6386: Spurious "unterminated #if" Date: Sun, 21 Apr 2002 03:56:00 -0000 [thread overview] Message-ID: <20020421105601.15198.qmail@sources.redhat.com> (raw) The following reply was made to PR preprocessor/6386; it has been noted by GNATS. From: Neil Booth <neil@daikokuya.demon.co.uk> To: Andreas Schwab <schwab@suse.de> Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: preprocessor/6386: Spurious "unterminated #if" Date: Sun, 21 Apr 2002 11:50:59 +0100 Neil Booth wrote:- > * cppmacro.c (funlike_invocation_p): Don't step back over CPP_EOF. > testsuite: > * gcc.dg/cpp/endif.h, gcc.dg/cpp/endif.c: New tests. > > Index: cppmacro.c > =================================================================== > RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v > retrieving revision 1.98 > diff -u -p -r1.98 cppmacro.c > --- cppmacro.c 14 Apr 2002 18:42:46 -0000 1.98 > +++ cppmacro.c 20 Apr 2002 22:04:19 -0000 > @@ -632,12 +632,15 @@ funlike_invocation_p (pfile, node) > return collect_args (pfile, node); > } > > - /* Back up. We may have skipped padding, in which case backing up > - more than one token when expanding macros is in general too > - difficult. We re-insert it in its own context. */ > - _cpp_backup_tokens (pfile, 1); > - if (padding) > - push_token_context (pfile, NULL, padding, 1); > + if (token->type != CPP_EOF) > + { > + /* Back up. We may have skipped padding, in which case backing > + up more than one token when expanding macros is in general > + too difficult. We re-insert it in its own context. */ > + _cpp_backup_tokens (pfile, 1); > + if (padding) > + push_token_context (pfile, NULL, padding, 1); > + } Sadly, that wasn't quite enough. This is the patch I've committed. Neil. Index: cppmacro.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v retrieving revision 1.91.6.3 diff -u -p -r1.91.6.3 cppmacro.c --- cppmacro.c 1 Apr 2002 21:16:43 -0000 1.91.6.3 +++ cppmacro.c 21 Apr 2002 10:47:48 -0000 @@ -646,12 +646,17 @@ funlike_invocation_p (pfile, node) return collect_args (pfile, node); } - /* Back up. We may have skipped padding, in which case backing up - more than one token when expanding macros is in general too - difficult. We re-insert it in its own context. */ - _cpp_backup_tokens (pfile, 1); - if (padding) - push_token_context (pfile, NULL, padding, 1); + /* CPP_EOF can be the end of macro arguments, or the end of the + file. We mustn't back up over the latter. Ugh. */ + if (token->type != CPP_EOF || token == &pfile->eof) + { + /* Back up. We may have skipped padding, in which case backing + up more than one token when expanding macros is in general + too difficult. We re-insert it in its own context. */ + _cpp_backup_tokens (pfile, 1); + if (padding) + push_token_context (pfile, NULL, padding, 1); + } return NULL; }
next reply other threads:[~2002-04-21 10:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-21 3:56 Neil Booth [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-04-21 9:13 neil 2002-04-20 15:16 Neil Booth 2002-04-20 14:26 Andreas Schwab
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=20020421105601.15198.qmail@sources.redhat.com \ --to=neil@daikokuya.demon.co.uk \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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: linkBe 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).