Commit 280fa93e by Jason Merrill Committed by Jason Merrill

PR c++/82764 - C++17 ICE with empty base

	* class.c (build_base_field_1): Set DECL_SIZE to zero for empty
	base.

From-SVN: r257745
parent 9dc20710
2018-02-16 Jason Merrill <jason@redhat.com>
PR c++/82764 - C++17 ICE with empty base
* class.c (build_base_field_1): Set DECL_SIZE to zero for empty base.
2018-02-16 Jason Merrill <jason@redhat.com>
PR c++/84421 - type-dependent if constexpr
* semantics.c (finish_if_stmt_cond): Check type_dependent_expression_p.
......
......@@ -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));
......
// PR c++/82764
// { dg-do compile { target c++11 } }
struct Empty {};
struct Empty2 : Empty {};
struct A : Empty2
{
int x {1};
int y {2};
};
struct B
{
A a {};
};
B b;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment