aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constraint.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-03-28 14:15:16 -0400
committerPatrick Palka <ppalka@redhat.com>2022-03-28 14:15:16 -0400
commitecb4882e362e80a1bf172453ac9b366edbb4e89c (patch)
treeaffd7c4814adc8fa6273b8669ce384ff2f4219b7 /gcc/cp/constraint.cc
parentcccbb776589c1825de1bd2eefabb11d72ef28de8 (diff)
downloadgcc-ecb4882e362e80a1bf172453ac9b366edbb4e89c.zip
gcc-ecb4882e362e80a1bf172453ac9b366edbb4e89c.tar.gz
gcc-ecb4882e362e80a1bf172453ac9b366edbb4e89c.tar.bz2
c++: constrained template friend matching ICE [PR105064]
Here during declaration matching for the two constrained template friends, we crash from maybe_substitute_reqs_for because the second friend doesn't yet have DECL_TEMPLATE_INFO set (we're being called indirectly from push_template_decl). As far as I can tell, this situation happens only when declaring a constrained template friend within a non-template class (as in the testcase), in which case the substitution would be a no-op anyway. So this patch rearranges maybe_substitute_reqs_for to gracefully handle missing DECL_TEMPLATE_INFO by just skipping the substitution. PR c++/105064 gcc/cp/ChangeLog: * constraint.cc (maybe_substitute_reqs_for): Don't assume DECL_TEMPLATE_INFO is available. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-friend9.C: New test.
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r--gcc/cp/constraint.cc13
1 files changed, 4 insertions, 9 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index e14578b..c5a991b 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -1268,20 +1268,15 @@ remove_constraints (tree t)
for declaration matching. */
tree
-maybe_substitute_reqs_for (tree reqs, const_tree decl_)
+maybe_substitute_reqs_for (tree reqs, const_tree decl)
{
if (reqs == NULL_TREE)
return NULL_TREE;
- tree decl = CONST_CAST_TREE (decl_);
- tree result = STRIP_TEMPLATE (decl);
-
- if (DECL_UNIQUE_FRIEND_P (result))
+ decl = STRIP_TEMPLATE (decl);
+ if (DECL_UNIQUE_FRIEND_P (decl) && DECL_TEMPLATE_INFO (decl))
{
- tree tmpl = decl;
- if (TREE_CODE (decl) != TEMPLATE_DECL)
- tmpl = DECL_TI_TEMPLATE (result);
-
+ tree tmpl = DECL_TI_TEMPLATE (decl);
tree gargs = generic_targs_for (tmpl);
processing_template_decl_sentinel s;
if (uses_template_parms (gargs))