sub = build3 (COMPONENT_REF, inner_type, dest, field_index,
NULL_TREE);
+ /* We may need to add a copy constructor call if
+ the field has [[no_unique_address]]. */
if (unsafe_return_slot_p (sub))
{
- /* We may need to add a copy constructor call if
- the field has [[no_unique_address]]. */
+ /* But not if the initializer is an implicit ctor call
+ we just built in digest_init. */
+ if (TREE_CODE (value) == TARGET_EXPR
+ && TARGET_EXPR_LIST_INIT_P (value))
+ {
+ tree init = TARGET_EXPR_INITIAL (value);
+ if (init && TREE_CODE (init) == AGGR_INIT_EXPR
+ && AGGR_INIT_VIA_CTOR_P (init))
+ goto build_init;
+ }
+
releasing_vec args = make_tree_vector_single (value);
code = build_special_member_call
(sub, complete_ctor_identifier, &args, inner_type,
LOOKUP_NORMAL, tf_warning_or_error);
}
else
- code = build2 (INIT_EXPR, inner_type, sub, value);
+ {
+ build_init:
+ code = build2 (INIT_EXPR, inner_type, sub, value);
+ }
code = build_stmt (input_location, EXPR_STMT, code);
code = maybe_cleanup_point_expr_void (code);
add_stmt (code);