]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/28560 (Trouble with __attribute__ in template parameter)
authorJason Merrill <jason@redhat.com>
Wed, 23 Jan 2008 05:11:58 +0000 (00:11 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 23 Jan 2008 05:11:58 +0000 (00:11 -0500)
        PR c++/28560
        * decl.c (groktypename): Also ignore attributes on dependent
        possibly-class types.

From-SVN: r131755

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

index f9971d4943d6f896ef0a388d45574f4ee0316bbd..667f813b594770100e58fc8e4794b2943b9c0199 100644 (file)
@@ -9,6 +9,10 @@
 
 2008-01-22  Jason Merrill  <jason@redhat.com>
 
+       PR c++/28560
+       * decl.c (groktypename): Also ignore attributes on dependent 
+       possibly-class types.
+
        PR c++/34912
        * friend.c (do_friend): Check for prior declaration of a friend 
        function of a local class.
index 338e1ed5676b0844c890ef1c8e329d404c1d130a..4640adfb1c615dbf89a18e8a6a13324a9d886a5a 100644 (file)
@@ -3908,8 +3908,12 @@ groktypename (cp_decl_specifier_seq *type_specifiers,
   if (attrs)
     {
       if (CLASS_TYPE_P (type))
-       warning (OPT_Wattributes, "ignoring attributes applied to class type "
-                "outside of definition");
+       warning (OPT_Wattributes, "ignoring attributes applied to class type %qT "
+                "outside of definition", type);
+      else if (IS_AGGR_TYPE (type))
+       /* A template type parameter or other dependent type.  */
+       warning (OPT_Wattributes, "ignoring attributes applied to dependent "
+                "type %qT without an associated declaration", type);
       else
        cplus_decl_attributes (&type, attrs, 0);
     }
diff --git a/gcc/testsuite/g++.dg/ext/tmplattr8.C b/gcc/testsuite/g++.dg/ext/tmplattr8.C
new file mode 100644 (file)
index 0000000..4b8707a
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/28560
+
+template<typename> struct A {};
+
+template<int> struct B;
+
+template<int N> struct C :
+  A<typename B<N>::X __attribute__((unused))> {}; // { dg-warning "attribute" }