diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-01-03 12:16:13 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2018-01-03 12:16:13 +0000 |
commit | f45cd62173747486eb47105dd844c3125b456775 (patch) | |
tree | f6d5874b22a41e657dd0d804fcb300c68bfbf0ed /gcc/cp/cp-gimplify.c | |
parent | 214b95ee875aab3cb6f0db058dc8300497130d62 (diff) |
PR c++/83634
* cp-gimplify.c (cp_fold) <case NOP_EXPR>: If the operand folds to
error_mark_node, return error_mark_node.
* g++.dg/parse/pr83634.C: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@256174 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/cp-gimplify.c')
-rw-r--r-- | gcc/cp/cp-gimplify.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 4f607289539..c090ee7fcbd 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -2112,7 +2112,20 @@ cp_fold (tree x) case NON_LVALUE_EXPR: if (VOID_TYPE_P (TREE_TYPE (x))) - return x; + { + /* This is just to make sure we don't end up with casts to + void from error_mark_node. If we just return x, then + cp_fold_r might fold the operand into error_mark_node and + leave the conversion in the IR. STRIP_USELESS_TYPE_CONVERSION + during gimplification doesn't like such casts. + Don't create a new tree if op0 != TREE_OPERAND (x, 0), the + folding of the operand should be in the caches and if in cp_fold_r + it will modify it in place. */ + op0 = cp_fold (TREE_OPERAND (x, 0)); + if (op0 == error_mark_node) + x = error_mark_node; + break; + } loc = EXPR_LOCATION (x); op0 = cp_fold_maybe_rvalue (TREE_OPERAND (x, 0), rval_ops); |