aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-06-17 19:23:10 -0400
committerMarek Polacek <polacek@redhat.com>2020-06-18 08:32:21 -0400
commit81caacc273399c91ae3182021ad87bc2ba786039 (patch)
tree04a873f9ad95aa776b79676f9aad86e01070d0f5 /gcc/cp
parent2c53566539265f56df1c0a60dca6dfc30f2c621d (diff)
downloadgcc-81caacc273399c91ae3182021ad87bc2ba786039.zip
gcc-81caacc273399c91ae3182021ad87bc2ba786039.tar.gz
gcc-81caacc273399c91ae3182021ad87bc2ba786039.tar.bz2
c++: Fix tsubst ICE with invalid static_cast [PR95728]
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: tree placement = RECUR (TREE_OPERAND (t, 0)); // placement is now error_mark_node, so... for (; placement != NULL_TREE; placement = TREE_CHAIN (placement)) // ... this crashes If we just return, we avoid the ICE and improve the diagnostic a bit. gcc/cp/ChangeLog: PR c++/95728 * pt.c (tsubst_copy_and_build) <case NEW_EXPR>: Return error_mark_node if placement is erroneous. gcc/testsuite/ChangeLog: PR c++/95728 * g++.dg/template/cast6.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 07b9956..9732e3b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19633,6 +19633,8 @@ tsubst_copy_and_build (tree t,
if (placement == NULL_TREE)
placement_vec = NULL;
+ else if (placement == error_mark_node)
+ RETURN (error_mark_node);
else
{
placement_vec = make_tree_vector ();