PR c++/36816
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Oct 2009 16:09:31 +0000 (16:09 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 8 Oct 2009 16:09:31 +0000 (16:09 +0000)
* pt.c (maybe_adjust_types_for_deduction): Do rvalue ref adjustment
even when DEDUCE_EXACT.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152565 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 5f67204..063db18 100644 (file)
@@ -1,5 +1,9 @@
 2009-10-08  Jason Merrill  <jason@redhat.com>
 
+       PR c++/36816
+       * pt.c (maybe_adjust_types_for_deduction): Do rvalue ref adjustment
+       even when DEDUCE_EXACT.
+
        PR c++/37177
        * pt.c (resolve_nondeduced_context): New.
        * cvt.c (convert_to_void): Call it.
index 19d8c9a..148adab 100644 (file)
@@ -12906,7 +12906,17 @@ maybe_adjust_types_for_deduction (unification_kind_t strict,
       }
 
     case DEDUCE_EXACT:
-      /* There is nothing to do in this case.  */
+      /* Core issue #873: Do the DR606 thing (see below) for these cases,
+        too, but here handle it by stripping the reference from PARM
+        rather than by adding it to ARG.  */
+      if (TREE_CODE (*parm) == REFERENCE_TYPE
+         && TYPE_REF_IS_RVALUE (*parm)
+         && TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM
+         && cp_type_quals (TREE_TYPE (*parm)) == TYPE_UNQUALIFIED
+         && TREE_CODE (*arg) == REFERENCE_TYPE
+         && !TYPE_REF_IS_RVALUE (*arg))
+       *parm = TREE_TYPE (*parm);
+      /* Nothing else to do in this case.  */
       return 0;
 
     default:
index edfbe1d..2e0e705 100644 (file)
@@ -1,5 +1,7 @@
 2009-10-08  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/rv-deduce.C: New.
+
        PR c++/37177
        * g++.dg/cpp0x/variadic-throw.C: Adjust errors.
        * g++.dg/template/explicit-args2.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-deduce.C b/gcc/testsuite/g++.dg/cpp0x/rv-deduce.C
new file mode 100644 (file)
index 0000000..0435436
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/36816, core issue 873
+// { dg-options -std=c++0x }
+
+template <class T> void h (T&&) { }
+
+void (*pf)(int&)   = &h;
+template <> void h(char&);
+template void h(double&);