aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-12-03 10:28:25 -0500
committerPatrick Palka <ppalka@redhat.com>2022-12-03 10:28:25 -0500
commitb3912122c9dfaba6c8229e8f095885f69782ceda (patch)
treef8ec304030ba701fd7aa6200e3182cf0baa8eecf /gcc/cp/pt.cc
parent93574914e462e87e42dddd66b0dfbb9627662f33 (diff)
downloadgcc-b3912122c9dfaba6c8229e8f095885f69782ceda.zip
gcc-b3912122c9dfaba6c8229e8f095885f69782ceda.tar.gz
gcc-b3912122c9dfaba6c8229e8f095885f69782ceda.tar.bz2
c++: substituting CONST_DECL_USING_P enumerators [PR103081]
We implement class-scope using enum by injecting clones of the enum's CONST_DECLs as fields of the class, for which CONST_DECL_USING_P is true, so that qualified lookup naturally finds the enumerators. Substitution into such a CONST_DECL currently ICEs however, because we assume the DECL_CONTEXT is always the ENUMERAL_TYPE (which has TYPE_VALUES) but in this case it's the RECORD_TYPE for the class scope (which has TYPE_FIELDS). Since these CONST_DECLs appear to always be non-dependent, this patch fixes this by shortcutting substitution for CONST_DECLs that have non-dependent DECL_CONTEXT. This subsumes the existing (and seemingly dead) DECL_NAMESPACE_SCOPE_P early exit test and also benefits substitution into ordinary non-dependent CONST_DECLs. PR c++/103081 gcc/cp/ChangeLog: * pt.cc (tsubst_copy) <case CONST_DECL>: Generalize early exit test for namespace-scope decls to check dependence of the enclosing scope instead. Remove dead early exit test. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/using-enum-10.C: New test. * g++.dg/cpp2a/using-enum-10a.C: New test.
Diffstat (limited to 'gcc/cp/pt.cc')
-rw-r--r--gcc/cp/pt.cc7
1 files changed, 1 insertions, 6 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 3169161..bc8ea06 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -17066,13 +17066,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
if (DECL_TEMPLATE_PARM_P (t))
return tsubst_copy (DECL_INITIAL (t), args, complain, in_decl);
- /* There is no need to substitute into namespace-scope
- enumerators. */
- if (DECL_NAMESPACE_SCOPE_P (t))
+ if (!uses_template_parms (DECL_CONTEXT (t)))
return t;
- /* If ARGS is NULL, then T is known to be non-dependent. */
- if (args == NULL_TREE)
- return scalar_constant_value (t);
/* Unfortunately, we cannot just call lookup_name here.
Consider: