From f7d5a7cd6bc51675373bcc4ae16a79e77782d510 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 8 Oct 2009 12:09:31 -0400 Subject: [PATCH] re PR c++/36816 ([c++0x] error deducing template argument taking the address of rvalue reference template) PR c++/36816 * pt.c (maybe_adjust_types_for_deduction): Do rvalue ref adjustment even when DEDUCE_EXACT. From-SVN: r152565 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 12 +++++++++++- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp0x/rv-deduce.C | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/rv-deduce.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5f672041fff..063db183eb3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2009-10-08 Jason Merrill + 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 19d8c9a87df..148adab2cba 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index edfbe1df673..2e0e705c157 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2009-10-08 Jason Merrill + * 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 index 00000000000..043543631ad --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-deduce.C @@ -0,0 +1,8 @@ +// PR c++/36816, core issue 873 +// { dg-options -std=c++0x } + +template void h (T&&) { } + +void (*pf)(int&) = &h; +template <> void h(char&); +template void h(double&); -- 2.30.2