diff options
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index e48a04ade7d..afa5c41bfff 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4216,8 +4216,14 @@ build_base_field_1 (tree t, tree basetype, tree *&next_field) DECL_ARTIFICIAL (decl) = 1; DECL_IGNORED_P (decl) = 1; DECL_FIELD_CONTEXT (decl) = t; - DECL_SIZE (decl) = CLASSTYPE_SIZE (basetype); - DECL_SIZE_UNIT (decl) = CLASSTYPE_SIZE_UNIT (basetype); + if (is_empty_class (basetype)) + /* CLASSTYPE_SIZE is one byte, but the field needs to have size zero. */ + DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = size_zero_node; + else + { + DECL_SIZE (decl) = CLASSTYPE_SIZE (basetype); + DECL_SIZE_UNIT (decl) = CLASSTYPE_SIZE_UNIT (basetype); + } SET_DECL_ALIGN (decl, CLASSTYPE_ALIGN (basetype)); DECL_USER_ALIGN (decl) = CLASSTYPE_USER_ALIGN (basetype); SET_DECL_MODE (decl, TYPE_MODE (basetype)); @@ -7122,7 +7128,8 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) case CALL_EXPR: /* This is a call to a constructor, hence it's never zero. */ - if (TREE_HAS_CONSTRUCTOR (instance)) + if (CALL_EXPR_FN (instance) + && TREE_HAS_CONSTRUCTOR (instance)) { if (nonnull) *nonnull = 1; |