OSDN Git Service

PR c++/35315
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Mar 2011 15:06:41 +0000 (15:06 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Mar 2011 15:06:41 +0000 (15:06 +0000)
* c-common.c (handle_transparent_union_attribute): Don't
make a duplicate type in C++.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171145 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attrib32.C

index a0268fd..ca3db25 100644 (file)
@@ -1,3 +1,9 @@
+2011-03-18  Jason Merrill  <jason@redhat.com>
+
+       PR c++/35315
+       * c-common.c (handle_transparent_union_attribute): Don't
+       make a duplicate type in C++.
+
 2011-03-15  Jason Merrill  <jason@redhat.com>
 
        * c-common.c (max_constexpr_depth): New.
index 6674c58..799f815 100644 (file)
@@ -6152,6 +6152,7 @@ handle_transparent_union_attribute (tree *node, tree name,
       if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
        {
          if (TYPE_FIELDS (type) == NULL_TREE
+             || c_dialect_cxx ()
              || TYPE_MODE (type) != DECL_MODE (TYPE_FIELDS (type)))
            goto ignored;
 
index ac7e5ad..dcd19ea 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-18  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/ext/attrib32.C: Expect errors on the two-names case.
+
 2011-03-18  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR middle-end/47405
index 77f71de..e4dfe4e 100644 (file)
@@ -10,10 +10,10 @@ void bar()
   foo(0);
 }
 
-typedef union U1 { int i; } U2 __attribute__((transparent_union));
+typedef union U1 { int i; } U2 __attribute__((transparent_union)); // { dg-warning "ignored" }
 
-static void foo2(U1) {}
-static void foo2(U2) {}
+static void foo2(U1) {}                // { dg-error "previously defined" }
+static void foo2(U2) {}                // { dg-error "redefinition" }
 
 void bar2(U1 u1, U2 u2)
 {