aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-11-30 14:53:24 -0500
committerMarek Polacek <polacek@redhat.com>2020-12-02 14:34:38 -0500
commit4192ffd74c69e3fb6d761becc8e5117c3de42052 (patch)
tree48954a81d48f8b5cf2ac3dc60e36dfa1360af84e /gcc/cp
parentc68cae86bbe78100f263cc73ba9cbe452778f9e4 (diff)
downloadgcc-4192ffd74c69e3fb6d761becc8e5117c3de42052.zip
gcc-4192ffd74c69e3fb6d761becc8e5117c3de42052.tar.gz
gcc-4192ffd74c69e3fb6d761becc8e5117c3de42052.tar.bz2
c++: Fix tsubst ICE with invalid code [PR97993, PR97187]
I had a strong sense of deja vu when looking into this, and no wonder, since this is almost identical to c++/95728. Since r11-423 tsubst_copy_and_build/TREE_LIST uses tsubst_tree_list instead of open coding it. While the latter could return an error node wrapped in a TREE_LIST, the former can return a naked error node. That broke in tsubst_copy_and_build/NEW_EXPR, because we were accessing TREE_VALUE of an error node. gcc/cp/ChangeLog: PR c++/97187 PR c++/97993 * pt.c (tsubst_copy_and_build) <case NEW_EXPR>: Return error_mark_node if init is erroneous. gcc/testsuite/ChangeLog: PR c++/97187 PR c++/97993 * g++.dg/eh/crash2.C: New test. * g++.dg/template/crash132.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4fb0bc8..72d6cc3 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19829,6 +19829,8 @@ tsubst_copy_and_build (tree t,
parameter packs are of length zero. */
if (init == NULL_TREE && TREE_OPERAND (t, 3) == NULL_TREE)
init_vec = NULL;
+ else if (init == error_mark_node)
+ RETURN (error_mark_node);
else
{
init_vec = make_tree_vector ();