aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-11-15 12:17:55 -0500
committerPatrick Palka <ppalka@redhat.com>2023-11-15 12:17:55 -0500
commit40a7707a7ea3568cee2cd80cd7e83b7eda678410 (patch)
treebf2d05aab17fd5c15c4d2fd58b68480eb9048c6e /gcc/cp
parentd3f48f682271ed94ab6e9f6bc62418a62bd8ff26 (diff)
downloadgcc-40a7707a7ea3568cee2cd80cd7e83b7eda678410.zip
gcc-40a7707a7ea3568cee2cd80cd7e83b7eda678410.tar.gz
gcc-40a7707a7ea3568cee2cd80cd7e83b7eda678410.tar.bz2
c++: partially inst requires-expr in noexcept-spec [PR101043]
Here we're ICEing from strip_typedefs for the partially instantiated requires-expression when walking its REQUIRES_EXPR_EXTRA_ARGS which in this case is a TREE_LIST with non-empty TREE_PURPOSE (to hold the captured local specialization 't' as per build_extra_args) which strip_typedefs doesn't expect. We can probably skip walking REQUIRES_EXPR_EXTRA_ARGS at all since it shouldn't contain any typedefs in the first place, but it seems safer and more generally useful to just teach strip_typedefs to handle non-empty TREE_PURPOSE the obvious way. (The code asserts TREE_PURPOSE was empty even since since its inception i.e. r189298.) PR c++/101043 gcc/cp/ChangeLog: * tree.cc (strip_typedefs_expr) <case TREE_LIST>: Handle non-empty TREE_PURPOSE. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires37.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/tree.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index dc4126f..0736e8d 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -1911,19 +1911,24 @@ strip_typedefs_expr (tree t, bool *remove_attributes, unsigned int flags)
case TREE_LIST:
{
bool changed = false;
- releasing_vec vec;
+ auto_vec<tree_pair, 4> vec;
r = t;
for (; t; t = TREE_CHAIN (t))
{
- gcc_assert (!TREE_PURPOSE (t));
- tree elt = strip_typedefs (TREE_VALUE (t),
- remove_attributes, flags);
- if (elt != TREE_VALUE (t))
+ tree purpose = strip_typedefs (TREE_PURPOSE (t),
+ remove_attributes, flags);
+ tree value = strip_typedefs (TREE_VALUE (t),
+ remove_attributes, flags);
+ if (purpose != TREE_PURPOSE (t) || value != TREE_VALUE (t))
changed = true;
- vec_safe_push (vec, elt);
+ vec.safe_push ({purpose, value});
}
if (changed)
- r = build_tree_list_vec (vec);
+ {
+ r = NULL_TREE;
+ for (int i = vec.length () - 1; i >= 0; i--)
+ r = tree_cons (vec[i].first, vec[i].second, r);
+ }
return r;
}