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-7549] PR c++/96329: ICE-on-invalid-code error recovery.
Date: Tue,  8 Mar 2022 23:19:50 +0000 (GMT)	[thread overview]
Message-ID: <20220308231950.786713858D20@sourceware.org> (raw)

https://gcc.gnu.org/g:8ab72ec7c456c92989276f17fe0ae90a56932149

commit r12-7549-g8ab72ec7c456c92989276f17fe0ae90a56932149
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Tue Mar 8 23:18:34 2022 +0000

    PR c++/96329: ICE-on-invalid-code error recovery.
    
    This patch fixes PR c++/96329 which is an ICE-on-invalid-code regression
    affecting mainline.
    
    2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>
    
    gcc/cp/ChangeLog
            PR c++/96329
            * parser.cc (cp_parser_linkage_specification): Treat the case where
            linkage is error_mark_node as "invalid linkage-specification".
    
    gcc/testsuite/ChangeLog
            PR c++/96329
            * g++.dg/template/pr96329.C: New test case.

Diff:
---
 gcc/cp/parser.cc                        | 5 +++--
 gcc/testsuite/g++.dg/template/pr96329.C | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 20aab5eb6b1..dc2d39a8751 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -16148,8 +16148,9 @@ cp_parser_linkage_specification (cp_parser* parser, tree prefix_attr)
   /* Transform the literal into an identifier.  If the literal is a
      wide-character string, or contains embedded NULs, then we can't
      handle it as the user wants.  */
-  if (strlen (TREE_STRING_POINTER (linkage))
-      != (size_t) (TREE_STRING_LENGTH (linkage) - 1))
+  if (linkage == error_mark_node
+      || strlen (TREE_STRING_POINTER (linkage))
+	 != (size_t) (TREE_STRING_LENGTH (linkage) - 1))
     {
       cp_parser_error (parser, "invalid linkage-specification");
       /* Assume C++ linkage.  */
diff --git a/gcc/testsuite/g++.dg/template/pr96329.C b/gcc/testsuite/g++.dg/template/pr96329.C
new file mode 100644
index 00000000000..36643228afb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr96329.C
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-excess-errors "" } */
+
+extern "C" ""a


                 reply	other threads:[~2022-03-08 23:19 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=20220308231950.786713858D20@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).