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 011b24e..34d5101 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 96d4b72..ba45673 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;