]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/36816 ([c++0x] error deducing template argument taking the address of rvalu...
authorJason Merrill <jason@redhat.com>
Thu, 8 Oct 2009 16:09:31 +0000 (12:09 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 8 Oct 2009 16:09:31 +0000 (12:09 -0400)
PR c++/36816
* pt.c (maybe_adjust_types_for_deduction): Do rvalue ref adjustment
even when DEDUCE_EXACT.

From-SVN: r152565

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

index 5f672041fffa1da174bf03612e8b4767cd29f5e3..063db183eb37b1aec8a471b103b4518851bf1aab 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 19d8c9a87df25d9d00be4fa3119bc8e83559b40a..148adab2cbafd45dc8ac540b413af54255252b62 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 edfbe1df6739662956836f32ce646bce5551a589..2e0e705c157a0aa92a5ab216b9ee20466d35c9f0 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&);
This page took 0.125936 seconds and 5 git commands to generate.