PR c++/85062 - ICE with alignas in wrong place.
authorJason Merrill <jason@redhat.com>
Mon, 26 Mar 2018 16:30:41 +0000 (12:30 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 26 Mar 2018 16:30:41 +0000 (12:30 -0400)
* decl.c (grokdeclarator): Ignore attributes on type-specifiers
here.

From-SVN: r258859

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

index 011b24e90687f2dd7db984a3b074c4b03b45eac4..34d5101963d343c2ae771acbc8aae8f37dbd4e82 100644 (file)
@@ -1,5 +1,9 @@
 2018-03-26  Jason Merrill  <jason@redhat.com>
 
+       PR c++/85062 - ICE with alignas in wrong place.
+       * decl.c (grokdeclarator): Ignore attributes on type-specifiers
+       here.
+
        PR c++/85049 - ICE with __integer_pack.
        * pt.c (unify_pack_expansion): Don't try to deduce generated packs.
        * cp-tree.h (TEMPLATE_PARM_P): New.
index 96d4b723b4a19b87463e56bd9f00529724d51f77..ba456737e0e72b7c57f0850b0c982d611c24c2aa 100644 (file)
@@ -10946,10 +10946,10 @@ grokdeclarator (const cp_declarator *declarator,
 
   if (declspecs->std_attributes)
     {
-      /* Apply the c++11 attributes to the type preceding them.  */
-      input_location = declspecs->locations[ds_std_attribute];
-      decl_attributes (&type, declspecs->std_attributes, 0);
-      input_location = saved_loc;
+      location_t attr_loc = declspecs->locations[ds_std_attribute];
+      if (warning_at (attr_loc, OPT_Wattributes, "attribute ignored"))
+       inform (attr_loc, "an attribute that appertains to a type-specifier "
+               "is ignored");
     }
 
   /* Determine the type of the entity declared by recurring on the
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas16.C b/gcc/testsuite/g++.dg/cpp0x/alignas16.C
new file mode 100644 (file)
index 0000000..7c34992
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/85062
+// { dg-do compile { target c++11 } }
+
+template<typename... T> struct A
+{
+  int alignas(T...) i;         // { dg-warning "ignored" }
+};
+
+A<int> a;