From: Jason Merrill Date: Wed, 16 Mar 2011 20:03:56 +0000 (-0400) Subject: re PR c++/48113 ([C++0x] bind with tuple argument fails) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f8f122781fa0c372ec99151f6584f2678ff4e0fd;p=gcc.git re PR c++/48113 ([C++0x] bind with tuple argument fails) PR c++/48113 * typeck.c (convert_for_initialization): Use perform_implicit_conversion_flags. * call.c (standard_conversion): If LOOKUP_PREFER_RVALUE, set rvaluedness_matches_p on ck_rvalue. (convert_like_real) [ck_rvalue]: And restore it here. From-SVN: r171067 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 336c22e808c..4649d965ddf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 2011-03-16 Jason Merrill + PR c++/48113 + * typeck.c (convert_for_initialization): Use + perform_implicit_conversion_flags. + * call.c (standard_conversion): If LOOKUP_PREFER_RVALUE, set + rvaluedness_matches_p on ck_rvalue. + (convert_like_real) [ck_rvalue]: And restore it here. + PR c++/48115 * call.c (convert_arg_to_ellipsis): Handle incomplete type. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f75c2485e31..436c9569d48 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -98,7 +98,9 @@ struct conversion { BOOL_BITFIELD base_p : 1; /* If KIND is ck_ref_bind, true when either an lvalue reference is being bound to an lvalue expression or an rvalue reference is - being bound to an rvalue expression. */ + being bound to an rvalue expression. If KIND is ck_rvalue, + true when we should treat an lvalue as an rvalue (12.8p33). If + KIND is ck_base, always false. */ BOOL_BITFIELD rvaluedness_matches_p: 1; BOOL_BITFIELD check_narrowing: 1; /* The type of the expression resulting from the conversion. */ @@ -897,6 +899,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, } } conv = build_conv (ck_rvalue, from, conv); + if (flags & LOOKUP_PREFER_RVALUE) + conv->rvaluedness_matches_p = true; } /* Allow conversion between `__complex__' data types. */ @@ -5489,6 +5493,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, conversion (i.e. the second step of copy-initialization), so don't allow any more. */ flags |= LOOKUP_NO_CONVERSION; + if (convs->rvaluedness_matches_p) + flags |= LOOKUP_PREFER_RVALUE; if (TREE_CODE (expr) == TARGET_EXPR && TARGET_EXPR_LIST_INIT_P (expr)) /* Copy-list-initialization doesn't actually involve a copy. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c062f0fa5e4..0e8a6d79b34 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7454,7 +7454,7 @@ convert_for_initialization (tree exp, tree type, tree rhs, int flags, return rhs; if (MAYBE_CLASS_TYPE_P (type)) - return ocp_convert (type, rhs, CONV_IMPLICIT|CONV_FORCE_TEMP, flags); + return perform_implicit_conversion_flags (type, rhs, complain, flags); return convert_for_assignment (type, rhs, errtype, fndecl, parmnum, complain, flags); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca82c7409c7..dee4a8d4aa0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2011-03-16 Jason Merrill + + * g++.dg/cpp0x/sfinae6.C: New. + * gcc/testsuite/g++.dg/cpp0x/initlist38.C: Adjust expected error. + * gcc/testsuite/g++.dg/cpp0x/pr45908.C: Likewise. + * gcc/testsuite/g++.dg/cpp0x/sfinae6.C: Likewise. + * gcc/testsuite/g++.old-deja/g++.jason/conversion11.C: Likewise. + * gcc/testsuite/g++.old-deja/g++.law/arg11.C: Likewise. + 2011-03-16 Jason Merrill * g++.dg/template/incomplete6.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist38.C b/gcc/testsuite/g++.dg/cpp0x/initlist38.C index 818d69ad654..32e20d591c7 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist38.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist38.C @@ -17,5 +17,5 @@ int main() f({}); B b0 = { }; B b1 { }; // OK, uses #1 - B b2 { 1 }; // { dg-error "conversion" } + B b2 { 1 }; // { dg-error "could not convert" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr45908.C b/gcc/testsuite/g++.dg/cpp0x/pr45908.C index 1a821e5d83b..3a8508890ee 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr45908.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr45908.C @@ -14,5 +14,5 @@ struct vector { class block { vector v; auto end() const -> decltype(v.begin()) - { return v.begin(); } // { dg-error "conversion" } + { return v.begin(); } // { dg-error "could not convert" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae6.C b/gcc/testsuite/g++.dg/cpp0x/sfinae6.C new file mode 100644 index 00000000000..401d5362d84 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae6.C @@ -0,0 +1,31 @@ +// PR c++/48113 +// { dg-options -std=c++0x } + +template T declval(); + +struct tuple { }; + +struct F1 +{ + void operator()(tuple, int); +}; + +typedef void (*F2)(tuple, int); + +template +struct Bind +{ + template(), A()) )> + R f(A); + + template(), A()) )> + R f(A) volatile; +}; + +int main() +{ + Bind().f(0); // OK + Bind().f(0); // ERROR, should be OK +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C index 607cf9cc841..6621a27b6a2 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C @@ -21,7 +21,7 @@ void DoSomething(Ding A); void foo(Something* pX) { - DoSomething(1); // { dg-error "conversion" } + DoSomething(1); // { dg-error "could not convert" } pX->DoSomething(1); // { dg-error "no matching" } // { dg-message "candidate" "candidate note" { target *-*-* } 25 } (*pX).DoSomething(1); // { dg-error "no matching" } diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg11.C b/gcc/testsuite/g++.old-deja/g++.law/arg11.C index fc590c4387a..fc9357964f4 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/arg11.C +++ b/gcc/testsuite/g++.old-deja/g++.law/arg11.C @@ -16,7 +16,7 @@ void function(Ack); int foo(S *o) { // Neither call has a usable constructor for conversions of char[5] to Ack. - function("adsf");// { dg-error "conversion" } + function("adsf");// { dg-error "could not convert" } o->method("adsf");// { dg-error "no matching" } // { dg-message "candidate" "candidate note" { target *-*-* } 20 } return 0;