re PR c++/53761 (ICE on incorrect transparent union (first field has floating point...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 25 Oct 2012 16:14:59 +0000 (16:14 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 25 Oct 2012 16:14:59 +0000 (16:14 +0000)
/cp
2012-10-25  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53761
* class.c (finish_struct_1): Reject aggregates decorated with
__transparent_union__ which cannot be made transparent because
the type of the first field has a different ABI from the class
overall.

/testsuite
2012-10-25  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53761
* g++.dg/ext/transparent-union.C: New.

From-SVN: r192814

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/transparent-union.C [new file with mode: 0644]

index 458f39abc7e24943cd9045d88462441c6dff7fcf..3cd3b27bc17b9176009f8697113daffc4033ceb4 100644 (file)
@@ -1,3 +1,11 @@
+2012-10-25  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53761
+       * class.c (finish_struct_1): Reject aggregates decorated with
+       __transparent_union__ which cannot be made transparent because
+       the type of the first field has a different ABI from the class
+       overall.
+
 2012-10-25  Jason Merrill  <jason@redhat.com>
 
        Core 1402
index 3e1b44a4c1ec4371b5caaf1975ed6718a91d8ab2..e55f1f9c2b78f8cdfb100db2ae5a9ba9101c7023 100644 (file)
@@ -6267,7 +6267,7 @@ finish_struct_1 (tree t)
       tree field = first_field (t);
       if (field == NULL_TREE || error_operand_p (field))
        {
-         error ("type transparent class %qT does not have any fields", t);
+         error ("type transparent %q#T does not have any fields", t);
          TYPE_TRANSPARENT_AGGR (t) = 0;
        }
       else if (DECL_ARTIFICIAL (field))
@@ -6281,6 +6281,13 @@ finish_struct_1 (tree t)
            }
          TYPE_TRANSPARENT_AGGR (t) = 0;
        }
+      else if (TYPE_MODE (t) != DECL_MODE (field))
+       {
+         error ("type transparent %q#T cannot be made transparent because "
+                "the type of the first field has a different ABI from the "
+                "class overall", t);
+         TYPE_TRANSPARENT_AGGR (t) = 0;
+       }
     }
 }
 
index 30fced628560b541596de1bde0bb52f7b62788be..16c0ce6c1b9f07df26e2275a35b3f911b6f70ad6 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-25  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53761
+       * g++.dg/ext/transparent-union.C: New.
+
 2012-10-25  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/54427
diff --git a/gcc/testsuite/g++.dg/ext/transparent-union.C b/gcc/testsuite/g++.dg/ext/transparent-union.C
new file mode 100644 (file)
index 0000000..1231563
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/53761
+
+typedef union {    // { dg-error "type transparent" }
+   double x;
+} __attribute__(( __transparent_union__ )) example_t;