From c2c6f7447124d1c4c4b22c9b3a794b4e03c204e3 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 28 Mar 2011 20:04:54 -0400 Subject: [PATCH] re PR c++/48313 ([C++0x] std::bind with template function) PR c++/48313 * pt.c (maybe_adjust_types_for_deduction): Handle T&& deduction from overloaded function. From-SVN: r171643 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 5 ++++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 22bd6b83d06..e19dce9b090 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-03-28 Jason Merrill + PR c++/48313 + * pt.c (maybe_adjust_types_for_deduction): Handle T&& deduction + from overloaded function. + Core 1232 * call.c (build_array_conv): New. (implicit_conversion): Use it. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9032dd92dcb..dfc726a005a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13936,7 +13936,10 @@ maybe_adjust_types_for_deduction (unification_kind_t strict, && TYPE_REF_IS_RVALUE (*parm) && TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM && cp_type_quals (TREE_TYPE (*parm)) == TYPE_UNQUALIFIED - && arg_expr && real_lvalue_p (arg_expr)) + && (arg_expr ? real_lvalue_p (arg_expr) + /* try_one_overload doesn't provide an arg_expr, but + functions are always lvalues. */ + : TREE_CODE (*arg) == FUNCTION_TYPE)) *arg = build_reference_type (*arg); /* [temp.deduct.call] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 513805d0208..7b1a72ee8e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-03-28 Jason Merrill + + * g++.dg/cpp0x/rv-deduce2.C: New. + 2011-03-29 Jakub Jelinek PR debug/48203 diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C b/gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C new file mode 100644 index 00000000000..160296f640f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C @@ -0,0 +1,18 @@ +// PR c++/48313 +// { dg-options -std=c++0x } + +template +void f(F&&) { } + +void g() { } + +template void h() { } + +int main() +{ + f( g ); // OK + void (&p)() = h; + f( p ); // OK + f( h ); // ??? +} + -- 2.30.2