re PR c++/3395 (Attribute causes type lookup to fail. Regression.)
authorJason Merrill <jason@redhat.com>
Thu, 31 Jan 2002 22:52:11 +0000 (17:52 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 31 Jan 2002 22:52:11 +0000 (17:52 -0500)
        PR c++/3395
        * decl.c (xref_tag): Remember early attributes in TYPE_ATTRIBUTES,
        not TREE_TYPE.
        * semantics.c (finish_class_definition): Adjust.

From-SVN: r49380

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

index f259c96e13aaa6dc6c71347e1a343cfca41f3548..c73ec0687ca692b7855d71c32799e4f4869d0410 100644 (file)
@@ -1,5 +1,10 @@
 2002-01-31  Jason Merrill  <jason@redhat.com>
 
+       PR c++/3395
+       * decl.c (xref_tag): Remember early attributes in TYPE_ATTRIBUTES,
+       not TREE_TYPE.
+       * semantics.c (finish_class_definition): Adjust.
+
        Allow attributes in parms and casts.
        * parse.y (named_parm): Don't strip attrs.
        (declmods): Remove 'attributes' production.
index e5d1a47e3970edad1e062ca47931d2723b1fd6dd..a5d9c64767cdae586e2cb614daa79e9de2b29113 100644 (file)
@@ -12881,7 +12881,7 @@ xref_tag (code_type_node, name, globalize)
        CLASSTYPE_DECLARED_CLASS (ref) = 0;
     }
 
-  TREE_TYPE (ref) = attributes;
+  TYPE_ATTRIBUTES (ref) = attributes;
 
   return ref;
 }
index 37729bfd9670c6b0a8a770460abfe7df3427dbb5..603326ce9d972cbc93c17728c9f8795516a8029f 100644 (file)
@@ -1891,8 +1891,8 @@ finish_class_definition (t, attributes, semi, pop_scope_p)
 
   /* If we got any attributes in class_head, xref_tag will stick them in
      TREE_TYPE of the type.  Grab them now.  */
-  attributes = chainon (TREE_TYPE (t), attributes);
-  TREE_TYPE (t) = NULL_TREE;
+  attributes = chainon (TYPE_ATTRIBUTES (t), attributes);
+  TYPE_ATTRIBUTES (t) = NULL_TREE;
 
   if (TREE_CODE (t) == ENUMERAL_TYPE)
     ;
diff --git a/gcc/testsuite/g++.dg/ext/attrib2.C b/gcc/testsuite/g++.dg/ext/attrib2.C
new file mode 100644 (file)
index 0000000..a7563f3
--- /dev/null
@@ -0,0 +1,12 @@
+// Test that an early attribute doesn't confuse uses of a class.
+// { dg-do compile }
+
+struct __attribute__ ((packed)) A
+{
+  void f () const;
+};
+
+void
+A::f () const
+{
+}