diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-01-03 13:16:13 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-01-03 13:16:13 +0100 |
commit | 19c37faad10950f693872a4be018cfd9bc81804a (patch) | |
tree | f6d5874b22a41e657dd0d804fcb300c68bfbf0ed | |
parent | 8987beac8c4bf6e0b99cb298126041da21964ca4 (diff) | |
download | gcc-19c37faad10950f693872a4be018cfd9bc81804a.zip gcc-19c37faad10950f693872a4be018cfd9bc81804a.tar.gz gcc-19c37faad10950f693872a4be018cfd9bc81804a.tar.bz2 |
re PR c++/83634 (ICE in useless_type_conversion_p, at gimple-expr.c:86)
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.
From-SVN: r256174
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/pr83634.C | 11 |
4 files changed, 34 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 750a9a8..9dfb293 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-01-03 Jakub Jelinek <jakub@redhat.com> + PR c++/83634 + * cp-gimplify.c (cp_fold) <case NOP_EXPR>: If the operand folds to + error_mark_node, return error_mark_node. + Update copyright years. 2018-01-02 Jakub Jelinek <jakub@redhat.com> diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 4f60728..c090ee7 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 822c29d..cff788b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-03 Jakub Jelinek <jakub@redhat.com> + + PR c++/83634 + * g++.dg/parse/pr83634.C: New test. + 2018-01-03 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/83664 diff --git a/gcc/testsuite/g++.dg/parse/pr83634.C b/gcc/testsuite/g++.dg/parse/pr83634.C new file mode 100644 index 0000000..70a396e --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr83634.C @@ -0,0 +1,11 @@ +// PR c++/83634 +// { dg-do compile } + +void +foo () +{ + const int x = fn (); // { dg-error "was not declared in this scope" } + short n; + for (n = x; n < 100; ++n) + ; +} |