diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-07-09 10:20:22 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-07-09 10:20:22 -0400 |
commit | f53e66019df819f55d424cc56f8b0ea81c074b55 (patch) | |
tree | b8618b7c104b03a9a02f6702bc4b3d39bc0b8289 /gcc/ada/gcc-interface/utils.c | |
parent | 2e345e4ad6bb6595a9e3b182aa349d4f306b0921 (diff) | |
download | gcc-f53e66019df819f55d424cc56f8b0ea81c074b55.zip gcc-f53e66019df819f55d424cc56f8b0ea81c074b55.tar.gz gcc-f53e66019df819f55d424cc56f8b0ea81c074b55.tar.bz2 |
c++: find_template_parameters and TEMPLATE_DECLs [PR101247]
r12-1989 fixed the testcase in the PR, but unfortunately the fix is
buggy: it breaks the case where the common template between the
TEMPLATE_DECL t and ctx_parms is the innermost template (as in
concepts-memtmpl5.C below). This can be fixed by instead passing the
TREE_TYPE of ctmpl to common_enclosing_class when ctmpl is a class
template.
But even after that's fixed, the analogous case where the innermost
template is a partial specialization is still broken (as in
concepts-memtmpl5a.C below), because ctmpl is always a primary template.
So this patch instead takes a diferent approach that doesn't rely on
ctx_parms at all: when looking for the template parameters of a
TEMPLATE_DECL that are shared with the current template context, just
walk its DECL_CONTEXT. As long as the template is not overly general
(e.g. we didn't pass it through most_general_template), this should give
us exactly what we want, since if a TEMPLATE_DECL can be referred to
from some template context then the template parameters it uses must all
be in-scope and contained in its DECL_CONTEXT. This effectively makes
us treat TEMPLATE_DECLs more similarly to other _DECLs (whose DECL_CONTEXT
we also walk).
PR c++/101247
gcc/cp/ChangeLog:
* pt.c (any_template_parm_r) <case TEMPLATE_DECL>: Just walk the
DECL_CONTEXT.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-memtmpl4.C: Uncomment the commented out
example, which we now handle correctly.
* g++.dg/cpp2a/concepts-memtmpl5.C: New test.
* g++.dg/cpp2a/concepts-memtmpl5a.C: New test.
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
0 files changed, 0 insertions, 0 deletions