diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-25 16:14:59 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-25 16:14:59 +0000 |
commit | 1ca4bd4a650994c359974198c534b20fec92e372 (patch) | |
tree | 64f3e00ee1e86736bdb2e4f38aaf2db7d77e5611 | |
parent | ecb10e6a777c616a80b4b2d36eb3b6978a638ac3 (diff) | |
download | gcc-1ca4bd4a650994c359974198c534b20fec92e372.tar.gz |
/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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192814 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/class.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/transparent-union.C | 5 |
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 458f39abc7e..3cd3b27bc17 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3e1b44a4c1e..e55f1f9c2b7 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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; + } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 30fced62856..16c0ce6c1b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 00000000000..12315636100 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/transparent-union.C @@ -0,0 +1,5 @@ +// PR c++/53761 + +typedef union { // { dg-error "type transparent" } + double x; +} __attribute__(( __transparent_union__ )) example_t; |