diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-04-29 00:23:01 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-04-29 00:23:01 +0200 |
commit | 8b80cc2131a7eb179a75392656b753d51045fb19 (patch) | |
tree | 8377c737763a3df6594340ecbe12fc8605d2c3f5 | |
parent | 9f405ce1b5bc4befcc4c2ac482e92f1662131659 (diff) | |
download | gcc-8b80cc2131a7eb179a75392656b753d51045fb19.zip gcc-8b80cc2131a7eb179a75392656b753d51045fb19.tar.gz gcc-8b80cc2131a7eb179a75392656b753d51045fb19.tar.bz2 |
re PR middle-end/70843 (ICE in add_expr, at tree.c:7913)
PR middle-end/70843
* fold-const.c (operand_equal_p): Don't verify hash value equality
if arg0 == arg1.
* tree.c (inchash::add_expr): Handle STATEMENT_LIST. Ignore BLOCK
and OMP_CLAUSE.
* gcc.dg/pr70843.c: New test.
From-SVN: r235615
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fold-const.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr70843.c | 9 | ||||
-rw-r--r-- | gcc/tree.c | 12 |
5 files changed, 43 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a23ed8..400a65a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-04-29 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/70843 + * fold-const.c (operand_equal_p): Don't verify hash value equality + if arg0 == arg1. + * tree.c (inchash::add_expr): Handle STATEMENT_LIST. Ignore BLOCK + and OMP_CLAUSE. + 2016-04-28 Jakub Jelinek <jakub@redhat.com> PR target/70858 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 96d8484..69749a8 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2756,12 +2756,15 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) { if (operand_equal_p (arg0, arg1, flags | OEP_NO_HASH_CHECK)) { - inchash::hash hstate0 (0), hstate1 (0); - inchash::add_expr (arg0, hstate0, flags); - inchash::add_expr (arg1, hstate1, flags); - hashval_t h0 = hstate0.end (); - hashval_t h1 = hstate1.end (); - gcc_assert (h0 == h1); + if (arg0 != arg1) + { + inchash::hash hstate0 (0), hstate1 (0); + inchash::add_expr (arg0, hstate0, flags); + inchash::add_expr (arg1, hstate1, flags); + hashval_t h0 = hstate0.end (); + hashval_t h1 = hstate1.end (); + gcc_assert (h0 == h1); + } return 1; } else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 595e3a8..d9e1e03 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-29 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/70843 + * gcc.dg/pr70843.c: New test. + 2016-04-28 Jakub Jelinek <jakub@redhat.com> PR target/70858 diff --git a/gcc/testsuite/gcc.dg/pr70843.c b/gcc/testsuite/gcc.dg/pr70843.c new file mode 100644 index 0000000..c3c9212 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr70843.c @@ -0,0 +1,9 @@ +/* PR middle-end/70843 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (int x, int y) +{ + return ({ int a = 5; a += x; a *= y; a; }) ? : 2; +} @@ -7836,6 +7836,10 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags) case PLACEHOLDER_EXPR: /* The node itself doesn't matter. */ return; + case BLOCK: + case OMP_CLAUSE: + /* Ignore. */ + return; case TREE_LIST: /* A list of expressions, for a CALL_EXPR or as the elements of a VECTOR_CST. */ @@ -7854,6 +7858,14 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags) } return; } + case STATEMENT_LIST: + { + tree_stmt_iterator i; + for (i = tsi_start (CONST_CAST_TREE (t)); + !tsi_end_p (i); tsi_next (&i)) + inchash::add_expr (tsi_stmt (i), hstate, flags); + return; + } case FUNCTION_DECL: /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form. Otherwise nodes that compare equal according to operand_equal_p might |