Hi,

On 12/01/2018 19:13, Jason Merrill wrote:
Hmm, I think dropping the attributes is reasonable for grokdeclarator
to do as error-recovery, similarly to how it discards an ill-formed
exception-specification.  But let's assert seen_error() in that case.
Agreed. The below passes testing.

Thanks!
Paolo.

///////////////////////
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 256592)
+++ cp/decl.c   (working copy)
@@ -11487,9 +11487,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: testsuite/g++.dg/cpp0x/alignas13.C
===================================================================
--- testsuite/g++.dg/cpp0x/alignas13.C  (nonexistent)
+++ testsuite/g++.dg/cpp0x/alignas13.C  (working copy)
@@ -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 '\\)'" }

Reply via email to