From 5557e6c93a7f6d708f68deb9acbd8769c00b72a0 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 16 Feb 2018 16:44:26 +0000 Subject: PR c++/82764 - C++17 ICE with empty base * class.c (build_base_field_1): Set DECL_SIZE to zero for empty base. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257745 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index e48a04ade7d..296305ea644 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)); -- cgit v1.2.1 From 75436625c318e592bd670220a5c00c288efc5e4f Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 20 Feb 2018 08:22:31 +0000 Subject: PR c++/84445 * class.c (fixed_type_or_null) : Only test TREE_HAS_CONSTRUCTOR if instance is not an internal function call. * g++.dg/cpp1z/launder7.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257840 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 296305ea644..afa5c41bfff 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -7128,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; -- cgit v1.2.1