Commit 156d614f by Jason Merrill Committed by Jason Merrill

re PR c++/34824 (ICE with explicit copy constructor)

        PR c++/34824
        * call.c (convert_like_real): Pass LOOKUP_ONLYCONVERTING to build_temp
        if we're doing conversions to call a user-defined conversion function.

From-SVN: r132282
parent 7f7682fe
2008-02-12 Jason Merrill <jason@redhat.com>
PR c++/34824
* call.c (convert_like_real): Pass LOOKUP_ONLYCONVERTING to build_temp
if we're doing conversions to call a user-defined conversion function.
2008-02-12 Steven Bosscher <steven@gcc.gnu.org> 2008-02-12 Steven Bosscher <steven@gcc.gnu.org>
PR c++/29048 PR c++/29048
......
...@@ -4319,6 +4319,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, ...@@ -4319,6 +4319,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
{ {
tree totype = convs->type; tree totype = convs->type;
diagnostic_fn_t diagnostic_fn; diagnostic_fn_t diagnostic_fn;
int flags;
if (convs->bad_p if (convs->bad_p
&& convs->kind != ck_user && convs->kind != ck_user
...@@ -4357,6 +4358,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, ...@@ -4357,6 +4358,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
{ {
struct z_candidate *cand = convs->cand; struct z_candidate *cand = convs->cand;
tree convfn = cand->fn; tree convfn = cand->fn;
unsigned i;
/* Set user_conv_p on the argument conversions, so rvalue/base
handling knows not to allow any more UDCs. */
for (i = 0; i < cand->num_convs; ++i)
cand->convs[i]->user_conv_p = true;
expr = build_over_call (cand, LOOKUP_NORMAL); expr = build_over_call (cand, LOOKUP_NORMAL);
...@@ -4454,8 +4461,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, ...@@ -4454,8 +4461,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
/* Copy-initialization where the cv-unqualified version of the source /* Copy-initialization where the cv-unqualified version of the source
type is the same class as, or a derived class of, the class of the type is the same class as, or a derived class of, the class of the
destination [is treated as direct-initialization]. [dcl.init] */ destination [is treated as direct-initialization]. [dcl.init] */
expr = build_temp (expr, totype, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING, flags = LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING;
&diagnostic_fn); if (convs->user_conv_p)
/* This conversion is being done in the context of a user-defined
conversion, so don't allow any more. */
flags |= LOOKUP_NO_CONVERSION;
expr = build_temp (expr, totype, flags, &diagnostic_fn);
if (diagnostic_fn && fn) if (diagnostic_fn && fn)
diagnostic_fn (" initializing argument %P of %qD", argnum, fn); diagnostic_fn (" initializing argument %P of %qD", argnum, fn);
return build_cplus_new (totype, expr); return build_cplus_new (totype, expr);
......
// PR c++/34824
struct A;
struct B
{
B (A const &); // { dg-warning "note" }
B (B &); // { dg-warning "note" }
};
struct A
{
A (B);
};
B
f (B const& b)
{
return b; // { dg-error "" }
}
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