extern tree get_type_value (tree);
extern tree build_zero_init (tree, tree, bool);
extern tree build_value_init (tree);
+extern tree build_value_init_noctor (tree);
extern tree build_offset_ref (tree, tree, bool);
extern tree build_new (tree, tree, tree, tree, int,
tsubst_flags_t);
AGGR_INIT_ZERO_FIRST (ctor) = 1;
return ctor;
}
- else if (TREE_CODE (type) != UNION_TYPE)
+ }
+ return build_value_init_noctor (type);
+}
+
+/* Like build_value_init, but don't call the constructor for TYPE. Used
+ for base initializers. */
+
+tree
+build_value_init_noctor (tree type)
+{
+ if (CLASS_TYPE_P (type))
+ {
+ gcc_assert (!TYPE_NEEDS_CONSTRUCTING (type));
+
+ if (TREE_CODE (type) != UNION_TYPE)
{
tree field;
VEC(constructor_elt,gc) *v = NULL;
"copy constructor",
current_function_decl, BINFO_TYPE (subobject));
- /* If an explicit -- but empty -- initializer list was present,
- treat it just like default initialization at this point. */
- if (arguments == void_type_node)
- arguments = NULL_TREE;
-
/* Initialize the base. */
if (BINFO_VIRTUAL_P (subobject))
construct_virtual_base (subobject, arguments);
return;
}
+ /* If an explicit -- but empty -- initializer list was present,
+ that's value-initialization. */
+ if (init == void_type_node)
+ {
+ /* If there's a user-provided constructor, we just call that. */
+ if (type_has_user_provided_constructor (type))
+ /* Fall through. */;
+ /* If there isn't, but we still need to call the constructor,
+ zero out the object first. */
+ else if (TYPE_NEEDS_CONSTRUCTING (type))
+ {
+ init = build_zero_init (type, NULL_TREE, /*static_storage_p=*/false);
+ init = build2 (INIT_EXPR, type, exp, init);
+ finish_expr_stmt (init);
+ /* And then call the constructor. */
+ }
+ /* If we don't need to mess with the constructor at all,
+ then just zero out the object and we're done. */
+ else
+ {
+ init = build2 (INIT_EXPR, type, exp, build_value_init_noctor (type));
+ finish_expr_stmt (init);
+ return;
+ }
+ init = NULL_TREE;
+ }
+
/* We know that expand_default_init can handle everything we want
at this point. */
expand_default_init (binfo, true_exp, exp, init, flags, complain);