aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-08-30 06:30:42 +0200
committerJason Merrill <jason@gcc.gnu.org>2011-08-30 00:30:42 -0400
commite7b6bcf3571f919b67a91141d56ddac2c377bbb7 (patch)
treec3aa7e49d511db97026e1be585dacf2e4f566369 /gcc/cp/class.c
parent25dd2fdd4040158f1802913cd8407a77b8d0441b (diff)
downloadgcc-e7b6bcf3571f919b67a91141d56ddac2c377bbb7.zip
gcc-e7b6bcf3571f919b67a91141d56ddac2c377bbb7.tar.gz
gcc-e7b6bcf3571f919b67a91141d56ddac2c377bbb7.tar.bz2
re PR c++/50207 (G++ segv's on reduced test case)
PR c++/50207 * class.c (finish_struct_1): Complain if the first field is artificial. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r178276
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 6ebe758..2a4bc77 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5795,10 +5795,25 @@ finish_struct_1 (tree t)
/* Finish debugging output for this type. */
rest_of_type_compilation (t, ! LOCAL_CLASS_P (t));
- if (TYPE_TRANSPARENT_AGGR (t) && first_field (t) == NULL_TREE)
+ if (TYPE_TRANSPARENT_AGGR (t))
{
- error ("type transparent class %qT does not have any fields", t);
- TYPE_TRANSPARENT_AGGR (t) = 0;
+ tree field = first_field (t);
+ if (field == NULL_TREE || error_operand_p (field))
+ {
+ error ("type transparent class %qT does not have any fields", t);
+ TYPE_TRANSPARENT_AGGR (t) = 0;
+ }
+ else if (DECL_ARTIFICIAL (field))
+ {
+ if (DECL_FIELD_IS_BASE (field))
+ error ("type transparent class %qT has base classes", t);
+ else
+ {
+ gcc_checking_assert (DECL_VIRTUAL_P (field));
+ error ("type transparent class %qT has virtual functions", t);
+ }
+ TYPE_TRANSPARENT_AGGR (t) = 0;
+ }
}
}