From 80f075b410125bddb31459428760645baba1a69f Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Sat, 10 Jun 2023 12:42:17 -0400 Subject: c++: Adjust conversion deduction [PR61663][DR976] Drop the return type's reference before doing cvqual and related decays. gcc/cp/ PR c++/61663 * pt.cc (maybe_adjust_types_for_deduction): Implement DR976. gcc/testsuite/ * g++.dg/template/pr61663.C: New. --- gcc/cp/pt.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gcc/cp') diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 6b20c58..6a2cf2c 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -22725,10 +22725,16 @@ maybe_adjust_types_for_deduction (tree tparms, break; case DEDUCE_CONV: + /* [temp.deduct.conv] First remove a reference type on parm. + DRs 322 & 976 affected this. */ + if (TYPE_REF_P (*parm)) + *parm = TREE_TYPE (*parm); + /* Swap PARM and ARG throughout the remainder of this function; the handling is precisely symmetric since PARM will initialize ARG rather than vice versa. */ std::swap (parm, arg); + break; case DEDUCE_EXACT: @@ -22795,11 +22801,6 @@ maybe_adjust_types_for_deduction (tree tparms, result |= UNIFY_ALLOW_OUTER_MORE_CV_QUAL; } - /* DR 322. For conversion deduction, remove a reference type on parm - too (which has been swapped into ARG). */ - if (strict == DEDUCE_CONV && TYPE_REF_P (*arg)) - *arg = TREE_TYPE (*arg); - return result; } -- cgit v1.1