tree convfn = cand->fn;
unsigned i;
+ /* If we're initializing from {}, it's value-initialization. */
+ if (BRACE_ENCLOSED_INITIALIZER_P (expr)
+ && CONSTRUCTOR_NELTS (expr) == 0
+ && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype))
+ {
+ expr = build_value_init (totype, complain);
+ expr = get_target_expr_sfinae (expr, complain);
+ if (expr != error_mark_node)
+ TARGET_EXPR_LIST_INIT_P (expr) = true;
+ return expr;
+ }
+
expr = mark_rvalue_use (expr);
/* When converting from an init list we consider explicit
{
int nelts = CONSTRUCTOR_NELTS (expr);
if (nelts == 0)
- expr = build_value_init (totype, tf_warning_or_error);
+ expr = build_value_init (totype, complain);
else if (nelts == 1)
expr = CONSTRUCTOR_ELT (expr, 0)->value;
else
&& BRACE_ENCLOSED_INITIALIZER_P (VEC_index (tree, *args, 0))
&& CONSTRUCTOR_IS_DIRECT_INIT (VEC_index (tree, *args, 0)))
{
+ tree init_list = VEC_index (tree, *args, 0);
+
gcc_assert (VEC_length (tree, *args) == 1
&& !(flags & LOOKUP_ONLYCONVERTING));
- add_list_candidates (fns, first_mem_arg, VEC_index (tree, *args, 0),
+ /* If the initializer list has no elements and T is a class type with
+ a default constructor, the object is value-initialized. Handle
+ this here so we don't need to handle it wherever we use
+ build_special_member_call. */
+ if (CONSTRUCTOR_NELTS (init_list) == 0
+ && TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype)
+ && !processing_template_decl)
+ {
+ tree ob, init = build_value_init (basetype, complain);
+ if (integer_zerop (instance_ptr))
+ return get_target_expr_sfinae (init, complain);
+ ob = build_fold_indirect_ref (instance_ptr);
+ init = build2 (INIT_EXPR, TREE_TYPE (ob), ob, init);
+ TREE_SIDE_EFFECTS (init) = true;
+ return init;
+ }
+
+ add_list_candidates (fns, first_mem_arg, init_list,
basetype, explicit_targs, template_only,
conversion_path, access_binfo, flags, &candidates);
}
permitted. If the conversion is valid, the converted expression is
returned. Otherwise, NULL_TREE is returned, except in the case
that TYPE is a class type; in that case, an error is issued. If
- C_CAST_P is true, then this direction initialization is taking
+ C_CAST_P is true, then this direct-initialization is taking
place as part of a static_cast being attempted as part of a C-style
cast. */