public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Roger Sayle <sayle@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-7573] PR c++/39751: ICE-on-invalid parsing regression.
Date: Thu, 10 Mar 2022 07:33:19 +0000 (GMT)	[thread overview]
Message-ID: <20220310073319.C38833858C2C@sourceware.org> (raw)

https://gcc.gnu.org/g:2185c9734ad977b88c519a4579187a91b3f71edd

commit r12-7573-g2185c9734ad977b88c519a4579187a91b3f71edd
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Thu Mar 10 07:32:06 2022 +0000

    PR c++/39751: ICE-on-invalid parsing regression.
    
    This is a fix for PR c++/39751 which is an ICE-on-invalid regression in
    the C++ parser after encountering the end of file.  The one line change
    is to check that the tokens cached in DECL_PENDING_INLINE_INFO haven't
    been purged before processing them in cp_parser_late_parsing_for_member.
    
    2022-03-10  Roger Sayle  <roger@nextmovesoftware.com>
    
    gcc/cp/ChangeLog
            PR c++/39751
            * parser.cc (cp_parser_late_parsing_for_member): Confirm the token
            stream hasn't been purged before processing DECL_PENDING_INLINE.
    
    gcc/testsuite/ChangeLog
            PR c++/39751
            * g++.dg/parse/pr39751.C: New test case.

Diff:
---
 gcc/cp/parser.cc                     |  5 +++--
 gcc/testsuite/g++.dg/parse/pr39751.C | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 5c342ca631b..18db9d40a01 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -32119,8 +32119,9 @@ cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function)
   maybe_begin_member_template_processing (member_function);
 
   /* If the body of the function has not yet been parsed, parse it
-     now.  */
-  if (DECL_PENDING_INLINE_P (member_function))
+     now.  Except if the tokens have been purged (PR c++/39751).  */
+  if (DECL_PENDING_INLINE_P (member_function)
+      && !DECL_PENDING_INLINE_INFO (member_function)->first->purged_p)
     {
       tree function_scope;
       cp_token_cache *tokens;
diff --git a/gcc/testsuite/g++.dg/parse/pr39751.C b/gcc/testsuite/g++.dg/parse/pr39751.C
new file mode 100644
index 00000000000..cfe803c6b2f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/pr39751.C
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+template < typename >
+struct A
+{
+A < struct
+{
+f () :
+
+// { dg-excess-errors "" }


                 reply	other threads:[~2022-03-10  7:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220310073319.C38833858C2C@sourceware.org \
    --to=sayle@gcc.gnu.org \
    --cc=gcc-cvs@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).