re PR c++/78344 (ICE on invalid c++ code on x86_64-linux-gnu (internal compiler error...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 17 Jan 2018 21:29:59 +0000 (21:29 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 17 Jan 2018 21:29:59 +0000 (21:29 +0000)
/cp
2018-01-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/78344
* decl.c (grokdeclarator): Do not append the error_mark_node
due to an erroneous optional attribute-specifier-seq.

/testsuite
2018-01-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/78344
* g++.dg/cpp0x/alignas13.C: New.

From-SVN: r256821

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/alignas13.C [new file with mode: 0644]

index 0d73c5b0f4a143707072f61ba3dbe55d80155c05..5978a6495592b5c5617e16f46f67f7e976a7d914 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/78344
+       * decl.c (grokdeclarator): Do not append the error_mark_node
+       due to an erroneous optional attribute-specifier-seq.
+
 2018-01-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/83897
index 148afa6c9ace158ae5ded668460c9c9520c8c26b..12022a2fdd8b51fe236303bb029ec7255c2e21ac 100644 (file)
@@ -11491,9 +11491,15 @@ grokdeclarator (const cp_declarator *declarator,
       && declarator->kind == cdk_id
       && declarator->std_attributes
       && attrlist != NULL)
-    /* [dcl.meaning]/1: The optional attribute-specifier-seq following
-       a declarator-id appertains to the entity that is declared.  */
-    *attrlist = chainon (*attrlist, declarator->std_attributes);
+    {
+      /* [dcl.meaning]/1: The optional attribute-specifier-seq following
+        a declarator-id appertains to the entity that is declared.  */
+      if (declarator->std_attributes != error_mark_node)
+       *attrlist = chainon (*attrlist, declarator->std_attributes);
+      else
+       /* We should have already diagnosed the issue (c++/78344).  */
+       gcc_assert (seen_error ());
+    }
 
   /* Handle parameter packs. */
   if (parameter_pack_p)
index 96495d9f7c6f6cdafa7ed4d880ef2211727502ab..364d044c721f27df2e6a3b51d0887c58581ac91f 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/78344
+       * g++.dg/cpp0x/alignas13.C: New.
+
 2018-01-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/83897
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas13.C b/gcc/testsuite/g++.dg/cpp0x/alignas13.C
new file mode 100644 (file)
index 0000000..4811b03
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/78344
+// { dg-do compile { target c++11 } }
+
+alignas(double) int f alignas;         // { dg-error "30:expected '\\('" }
+alignas(double) int g alignas(double;  // { dg-error "37:expected '\\)'" }