]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix deduction with reference NTTP [PR83476]
authorPatrick Palka <ppalka@redhat.com>
Wed, 14 Apr 2021 12:54:30 +0000 (08:54 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 11 May 2022 12:30:29 +0000 (08:30 -0400)
commitc6432e17960799509c48df6b500a8d069110980b
treea194c8955a03d076400204af883641d03d28d048
parentd042fa8e2cfabe5da83634ce05e8130d1010c034
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.

(cherry picked from commit 2ccc05a5141506fde0e20dec702c717fd67bf6ee)
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/class-deduction85.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/ref11.C [new file with mode: 0644]