]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: unqualified member template in constraint [PR101247]
authorPatrick Palka <ppalka@redhat.com>
Fri, 2 Jul 2021 17:54:57 +0000 (13:54 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 2 Jul 2021 17:54:57 +0000 (13:54 -0400)
commite3528ce197f8886869f95e8a8f901861a319851c
tree052326ad1c396e980b2467d1c88408ee9904ff98
parent42a9e4e1381ba14d8ef21b331494945c2f51e6be
c++: unqualified member template in constraint [PR101247]

Here any_template_parm_r is failing to mark the template parameters
implicitly used by the unqualified use of 'd' inside the constraint
because the code to do so assumes each level of a template parameter
list points to the corresponding primary template, but here the
parameter level for A in the out-of-line definition of A::B does not
(nor do the parameter levels for A and C in the definition of A::C),
which causes us to overlook the sharing.

So it seems we can't in general depend on the TREE_TYPE of a template
parameter level being non-empty here.  This patch partially fixes this
by rewriting the relevant part of any_template_parm_r to not depend on
the TREE_TYPE of outer levels.  We still depend on the innermost level
to point to the innermost primary template, so we still crash on the
commented out line in the below testcase.

PR c++/101247

gcc/cp/ChangeLog:

* pt.c (any_template_parm_r) <case TEMPLATE_DECL>: Rewrite to
use common_enclosing_class and to not depend on the TREE_TYPE
of outer levels pointing to the corresponding primary template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memtmpl4.C: New test.
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/concepts-memtmpl4.C [new file with mode: 0644]