aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/class.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ext/transparent-union.C5
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 458f39a..3cd3b27 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 3e1b44a..e55f1f9 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 30fced6..16c0ce6 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 0000000..1231563
--- /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;