re PR c++/48313 ([C++0x] std::bind with template function)
authorJason Merrill <jason@redhat.com>
Tue, 29 Mar 2011 00:04:54 +0000 (20:04 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 29 Mar 2011 00:04:54 +0000 (20:04 -0400)
PR c++/48313
* pt.c (maybe_adjust_types_for_deduction): Handle T&& deduction
from overloaded function.

From-SVN: r171643

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C [new file with mode: 0644]

index 22bd6b83d06916cea014cb896306f3e88e0ffed4..e19dce9b0907a56bfc5be72e380a37c93da30c82 100644 (file)
@@ -1,5 +1,9 @@
 2011-03-28  Jason Merrill  <jason@redhat.com>
 
+       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.
index 9032dd92dcb993260e190d1b918586ec12795d46..dfc726a005a3a30c2d4d5767cd2ce6d8525ef840 100644 (file)
@@ -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]
index 513805d02082e09acca08f9ca13f8a334ccc5017..7b1a72ee8e416c1bb904fedaf036971da6f13fc9 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-28  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/rv-deduce2.C: New.
+
 2011-03-29  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..160296f
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/48313
+// { dg-options -std=c++0x }
+
+template<typename F>
+void f(F&&) { }
+
+void g() { }
+
+template<typename T> void h() { }
+
+int main()
+{
+  f( g );       // OK
+  void (&p)() = h<int>;
+  f( p );       // OK
+  f( h<int> );  // ???
+}
+