From f2c8be187e8eb061e44166ac41646285821be6a6 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 21 Apr 2020 06:46:42 -0700 Subject: [PATCH] c++: ICE with ptr_plus_expr An ICE on darwin, when a SFINAE-context substitution produced error_mark_node foo an operand of a POINTER_PLUS_EXPR. fold_build_pointer_plus is unprepared to deal with that, so we need to check earlier. We had no luck reducing the testcase to something manageable. * pt.c (tsubst_copy_and_build) [POINTER_PLUS_EXPR]: Check for error_mark_node. --- gcc/cp/ChangeLog | 11 ++++++++--- gcc/cp/pt.c | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5b2bff8c561..81647d40b68 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2020-04-21 Nathan Sidwell + + * pt.c (tsubst_copy_and_build) [POINTER_PLUS_EXPR]: Check for + error_mark_node. + 2020-04-21 Iain Sandoe PR c++/94661 @@ -38,13 +43,13 @@ 2020-04-20 Nathan Sidwell - PR 94454 - tpl-tpl-parms are not canonicalizable types + PR c++/94454 - tpl-tpl-parms are not canonicalizable types * pt.c (canonical_type_parameter): Assert not a tpl-tpl-parm. (process_template_parm): tpl-tpl-parms are structural. (rewrite_template_parm): Propagate structuralness. - PR 94454 - Expr pack expansion equality - * tree.c (cp_tree_equal): [TEMPLATE_ID_EXPR, default] Refactor. + PR c++/94454 - Expr pack expansion equality + * tree.c (cp_tree_equal) [TEMPLATE_ID_EXPR, default]: Refactor. [EXPR_PACK_EXPANSION]: Add. PR c++/94454 Template Argument Hashing diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cd6392aca22..6f74c278c23 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -19409,7 +19409,11 @@ tsubst_copy_and_build (tree t, case POINTER_PLUS_EXPR: { tree op0 = RECUR (TREE_OPERAND (t, 0)); + if (op0 == error_mark_node) + RETURN (error_mark_node); tree op1 = RECUR (TREE_OPERAND (t, 1)); + if (op1 == error_mark_node) + RETURN (error_mark_node); RETURN (fold_build_pointer_plus (op0, op1)); } -- 2.30.2