Commit f8f12278 by Jason Merrill Committed by Jason Merrill

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
parent 85a273ba
2011-03-16 Jason Merrill <jason@redhat.com> 2011-03-16 Jason Merrill <jason@redhat.com>
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 PR c++/48115
* call.c (convert_arg_to_ellipsis): Handle incomplete type. * call.c (convert_arg_to_ellipsis): Handle incomplete type.
......
...@@ -98,7 +98,9 @@ struct conversion { ...@@ -98,7 +98,9 @@ struct conversion {
BOOL_BITFIELD base_p : 1; BOOL_BITFIELD base_p : 1;
/* If KIND is ck_ref_bind, true when either an lvalue reference is /* 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 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 rvaluedness_matches_p: 1;
BOOL_BITFIELD check_narrowing: 1; BOOL_BITFIELD check_narrowing: 1;
/* The type of the expression resulting from the conversion. */ /* 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, ...@@ -897,6 +899,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
} }
} }
conv = build_conv (ck_rvalue, from, conv); conv = build_conv (ck_rvalue, from, conv);
if (flags & LOOKUP_PREFER_RVALUE)
conv->rvaluedness_matches_p = true;
} }
/* Allow conversion between `__complex__' data types. */ /* Allow conversion between `__complex__' data types. */
...@@ -5489,6 +5493,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, ...@@ -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 conversion (i.e. the second step of copy-initialization), so
don't allow any more. */ don't allow any more. */
flags |= LOOKUP_NO_CONVERSION; flags |= LOOKUP_NO_CONVERSION;
if (convs->rvaluedness_matches_p)
flags |= LOOKUP_PREFER_RVALUE;
if (TREE_CODE (expr) == TARGET_EXPR if (TREE_CODE (expr) == TARGET_EXPR
&& TARGET_EXPR_LIST_INIT_P (expr)) && TARGET_EXPR_LIST_INIT_P (expr))
/* Copy-list-initialization doesn't actually involve a copy. */ /* Copy-list-initialization doesn't actually involve a copy. */
......
...@@ -7454,7 +7454,7 @@ convert_for_initialization (tree exp, tree type, tree rhs, int flags, ...@@ -7454,7 +7454,7 @@ convert_for_initialization (tree exp, tree type, tree rhs, int flags,
return rhs; return rhs;
if (MAYBE_CLASS_TYPE_P (type)) 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, return convert_for_assignment (type, rhs, errtype, fndecl, parmnum,
complain, flags); complain, flags);
......
2011-03-16 Jason Merrill <jason@redhat.com> 2011-03-16 Jason Merrill <jason@redhat.com>
* 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 <jason@redhat.com>
* g++.dg/template/incomplete6.C: New. * g++.dg/template/incomplete6.C: New.
2011-03-16 Jeff Law <law@redhat.com> 2011-03-16 Jeff Law <law@redhat.com>
......
...@@ -17,5 +17,5 @@ int main() ...@@ -17,5 +17,5 @@ int main()
f({}); f({});
B b0 = { }; B b0 = { };
B b1 { }; // OK, uses #1 B b1 { }; // OK, uses #1
B b2 { 1 }; // { dg-error "conversion" } B b2 { 1 }; // { dg-error "could not convert" }
} }
...@@ -14,5 +14,5 @@ struct vector { ...@@ -14,5 +14,5 @@ struct vector {
class block { class block {
vector v; vector v;
auto end() const -> decltype(v.begin()) auto end() const -> decltype(v.begin())
{ return v.begin(); } // { dg-error "conversion" } { return v.begin(); } // { dg-error "could not convert" }
}; };
// PR c++/48113
// { dg-options -std=c++0x }
template<typename T> T declval();
struct tuple { };
struct F1
{
void operator()(tuple, int);
};
typedef void (*F2)(tuple, int);
template<typename F, typename T>
struct Bind
{
template<typename A,
typename R = decltype( F()(declval<T&>(), A()) )>
R f(A);
template<typename A,
typename R = decltype( F()(declval<volatile T&>(), A()) )>
R f(A) volatile;
};
int main()
{
Bind<F1, tuple>().f(0); // OK
Bind<F2, tuple>().f(0); // ERROR, should be OK
}
...@@ -21,7 +21,7 @@ void DoSomething(Ding A); ...@@ -21,7 +21,7 @@ void DoSomething(Ding A);
void foo(Something* pX) void foo(Something* pX)
{ {
DoSomething(1); // { dg-error "conversion" } DoSomething(1); // { dg-error "could not convert" }
pX->DoSomething(1); // { dg-error "no matching" } pX->DoSomething(1); // { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 25 } // { dg-message "candidate" "candidate note" { target *-*-* } 25 }
(*pX).DoSomething(1); // { dg-error "no matching" } (*pX).DoSomething(1); // { dg-error "no matching" }
......
...@@ -16,7 +16,7 @@ void function(Ack); ...@@ -16,7 +16,7 @@ void function(Ack);
int int
foo(S *o) foo(S *o)
{ // Neither call has a usable constructor for conversions of char[5] to Ack. { // 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" } o->method("adsf");// { dg-error "no matching" }
// { dg-message "candidate" "candidate note" { target *-*-* } 20 } // { dg-message "candidate" "candidate note" { target *-*-* } 20 }
return 0; return 0;
......
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