Commit c4ce224c by Jason Merrill Committed by Jason Merrill

* init.c (expand_default_init): Unshare args in ctor delegation.

From-SVN: r182013
parent 238e471c
2011-12-05 Jason Merrill <jason@redhat.com>
* init.c (expand_default_init): Unshare args in ctor delegation.
2011-12-05 Ville Voutilainen <ville.voutilainen@gmail.com>
Pedro Lamarão <pedro.lamarao@gmail.com>
......
......@@ -1619,17 +1619,30 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags,
/* Delegating constructor. */
tree complete;
tree base;
tree elt; unsigned i;
/* Unshare the arguments for the second call. */
VEC(tree,gc) *parms2 = make_tree_vector ();
FOR_EACH_VEC_ELT (tree, parms, i, elt)
{
elt = break_out_target_exprs (elt);
VEC_safe_push (tree, gc, parms2, elt);
}
complete = build_special_member_call (exp, complete_ctor_identifier,
&parms, binfo, flags,
complain);
&parms2, binfo, flags,
complain);
complete = fold_build_cleanup_point_expr (void_type_node, complete);
release_tree_vector (parms2);
base = build_special_member_call (exp, base_ctor_identifier,
&parms, binfo, flags,
complain);
rval = build3 (COND_EXPR, TREE_TYPE (complete),
build2 (EQ_EXPR, boolean_type_node,
current_in_charge_parm, integer_zero_node),
base,
complete);
base = fold_build_cleanup_point_expr (void_type_node, base);
rval = build3 (COND_EXPR, void_type_node,
build2 (EQ_EXPR, boolean_type_node,
current_in_charge_parm, integer_zero_node),
base,
complete);
}
else
{
......
2011-12-05 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/dc6.C: New.
2011-12-05 Ville Voutilainen <ville.voutilainen@gmail.com>
Pedro Lamarão <pedro.lamarao@gmail.com>
......
// { dg-do run { target c++11 } }
int a_ct;
struct A
{
A(int i): i(i) { ++a_ct; }
A(const A& a): i(a.i) { ++a_ct; }
~A() { --a_ct; }
int i;
};
struct V
{
V() { }
};
struct B: virtual V
{
A a;
B(A a): a(a) { }
B(int i): B(A(i)) { }
};
struct C: B
{
C(int i): B(i) { }
};
int main()
{
{
B b(42);
C c(24);
if (b.a.i != 42
||c.a.i != 24)
__builtin_abort ();
}
return a_ct;
}
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