diff options
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 21 |
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; + } } } |