re PR c++/28558 (Trouble with __attribute__ and non-PODs)
authorJason Merrill <jason@redhat.com>
Tue, 28 Aug 2007 13:57:09 +0000 (09:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 28 Aug 2007 13:57:09 +0000 (09:57 -0400)
        PR c++/28558
        * cp/decl.c (groktypename): Ignore attributes applied to class type.
        * testsuite/g++.dg/ext/attrib28.C: New test.

From-SVN: r127859

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

index a6222faae7a85f780e6b85ab0dcbb6e0fa71a4f2..03d6b51c1a634c1c89d315f0bf6c79ba40f297f7 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/28558
+       * decl.c (groktypename): Ignore attributes applied to class type.
+
 2007-08-28  Richard Guenther  <rguenther@suse.de>
 
        * decl.c (duplicate_decls): Merge DECL_DISREGARD_INLINE_LIMITS.
index fdccb3542ad0281334b3d7abcc4d82888045521f..3117a7a33eb93812240ad776c6517b8b5190d46c 100644 (file)
@@ -3877,7 +3877,13 @@ groktypename (cp_decl_specifier_seq *type_specifiers,
   type_specifiers->attributes = NULL_TREE;
   type = grokdeclarator (declarator, type_specifiers, TYPENAME, 0, &attrs);
   if (attrs)
-    cplus_decl_attributes (&type, attrs, 0);
+    {
+      if (CLASS_TYPE_P (type))
+       warning (OPT_Wattributes, "ignoring attributes applied to class type "
+                "outside of definition");
+      else
+       cplus_decl_attributes (&type, attrs, 0);
+    }
   return type;
 }
 
index f3a78804c85ddad6b53f766bc00ea24ed2fccb67..b71ec15f82698005305af9c6949a2977e09fdd18 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-28  Jason Merrill  <jason@redhat.com>
+
+       PR c++/28558
+       * g++.dg/ext/attrib28.C: New test.
+
 2007-08-28  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/32661
diff --git a/gcc/testsuite/g++.dg/ext/attrib28.C b/gcc/testsuite/g++.dg/ext/attrib28.C
new file mode 100644 (file)
index 0000000..2f18d41
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/28558
+// { dg-options "" }
+
+struct A
+{
+  A(int) { }
+};
+
+int main()
+{
+  A a = (A __attribute__((unused)))0; // { dg-warning "attribute" }
+}