/* Not found. */
+ if (is_really_empty_class (elem_type, /*ignore_vptr*/false))
+ return build_constructor (elem_type, NULL);
+
if (TREE_CODE (ary) == CONSTRUCTOR
&& CONSTRUCTOR_NO_CLEARING (ary))
{
directly for non-aggregates to avoid creating a garbage CONSTRUCTOR. */
tree val;
constexpr_ctx new_ctx;
- if (is_really_empty_class (elem_type, /*ignore_vptr*/false))
- return build_constructor (elem_type, NULL);
- else if (CP_AGGREGATE_TYPE_P (elem_type))
+ if (CP_AGGREGATE_TYPE_P (elem_type))
{
tree empty_ctor = build_constructor (init_list_type_node, NULL);
val = digest_init (elem_type, empty_ctor, tf_warning_or_error);
FOR_EACH_CONSTRUCTOR_ELT (v, i, index, value)
{
tree orig_value = value;
- /* Like in cxx_eval_store_expression, omit entries for empty fields. */
- bool no_slot = TREE_CODE (type) == RECORD_TYPE && is_empty_field (index);
init_subob_ctx (ctx, new_ctx, index, value);
+ /* Like in cxx_eval_store_expression, omit entries for empty fields. */
+ bool no_slot = new_ctx.ctor == NULL_TREE;
int pos_hint = -1;
if (new_ctx.ctor != ctx->ctor && !no_slot)
{
bool reuse = false;
constexpr_ctx new_ctx;
init_subob_ctx (ctx, new_ctx, idx, pre_init ? init : elttype);
- if (new_ctx.ctor != ctx->ctor)
+ bool no_slot = new_ctx.ctor == NULL_TREE;
+ if (new_ctx.ctor != ctx->ctor && !no_slot)
{
if (zeroed_out)
CONSTRUCTOR_NO_CLEARING (new_ctx.ctor) = false;
}
if (*non_constant_p)
break;
- if (new_ctx.ctor != ctx->ctor)
+ if (no_slot)
+ {
+ /* This is an initializer for an empty subobject; now that we've
+ checked that it's constant, we can ignore it. */
+ gcc_checking_assert (i == 0);
+ break;
+ }
+ else if (new_ctx.ctor != ctx->ctor)
{
/* We appended this element above; update the value. */
gcc_assert ((*p)->last().index == idx);