aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-04-14 08:54:30 -0400
committerPatrick Palka <ppalka@redhat.com>2021-04-14 08:54:30 -0400
commit2ccc05a5141506fde0e20dec702c717fd67bf6ee (patch)
tree735c1fd797ead9d0ed3f1580391bb1aa5ffb1d4f /gcc/cp
parenta5e4abac26b815fe0b0d421930bfdfd2901adfe3 (diff)
downloadgcc-2ccc05a5141506fde0e20dec702c717fd67bf6ee.zip
gcc-2ccc05a5141506fde0e20dec702c717fd67bf6ee.tar.gz
gcc-2ccc05a5141506fde0e20dec702c717fd67bf6ee.tar.bz2
c++: Fix deduction with reference NTTP [PR83476]
In the testcase ref11.C below, during deduction for the call f(a), uses_deducible_template_parms returns false for the dependent specialization A<V> because the generic template argument V here is wrapped in an implicit INDIRECT_REF (formed from template_parm_to_arg). Since uses_deducible_template_parms returns false, unify_one_argument exits early without ever attempting to deduce 'n' for 'V'. This patch fixes this by making deducible_expression look through such implicit INDIRECT_REFs. gcc/cp/ChangeLog: PR c++/83476 PR c++/99885 * pt.c (deducible_expression): Look through implicit INDIRECT_REFs as well. gcc/testsuite/ChangeLog: PR c++/83476 PR c++/99885 * g++.dg/cpp1z/class-deduction85.C: New test. * g++.dg/template/ref11.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 59df794..f488a5a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -21902,8 +21902,10 @@ static bool uses_deducible_template_parms (tree type);
static bool
deducible_expression (tree expr)
{
- /* Strip implicit conversions. */
- while (CONVERT_EXPR_P (expr) || TREE_CODE (expr) == VIEW_CONVERT_EXPR)
+ /* Strip implicit conversions and implicit INDIRECT_REFs. */
+ while (CONVERT_EXPR_P (expr)
+ || TREE_CODE (expr) == VIEW_CONVERT_EXPR
+ || REFERENCE_REF_P (expr))
expr = TREE_OPERAND (expr, 0);
return (TREE_CODE (expr) == TEMPLATE_PARM_INDEX);
}