From: Marek Polacek Date: Thu, 26 Jan 2017 11:37:33 +0000 (+0000) Subject: re PR c/79199 (ICE with -Wduplicated-branches) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a38b341a8c6e6ee8357ca78c3105b7082337611;p=gcc.git re PR c/79199 (ICE with -Wduplicated-branches) PR c/79199 * fold-const.c (operand_equal_p) [COND_EXPR]: Use OP_SAME_WITH_NULL for the third operand. * c-c++-common/Wduplicated-branches-13.c: New test. From-SVN: r244928 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f485bb37255..eb0e7056415 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-01-26 Marek Polacek + + PR c/79199 + * fold-const.c (operand_equal_p) [COND_EXPR]: Use OP_SAME_WITH_NULL + for the third operand. + 2017-01-26 Jakub Jelinek PR middle-end/79236 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5576d592988..a8bb8af45c3 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3147,7 +3147,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) TREE_OPERAND (arg1, 0), flags)); case COND_EXPR: - if (! OP_SAME (1) || ! OP_SAME (2)) + if (! OP_SAME (1) || ! OP_SAME_WITH_NULL (2)) return 0; flags &= ~OEP_ADDRESS_OF; return OP_SAME (0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a65a68e3f6..6b5ecb417dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-26 Marek Polacek + + PR c/79199 + * c-c++-common/Wduplicated-branches-13.c: New test. + 2017-01-26 David Sherwood PR middle-end/79212 diff --git a/gcc/testsuite/c-c++-common/Wduplicated-branches-13.c b/gcc/testsuite/c-c++-common/Wduplicated-branches-13.c new file mode 100644 index 00000000000..7aa5b37cc69 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wduplicated-branches-13.c @@ -0,0 +1,23 @@ +/* PR c/79199 */ +/* { dg-do compile } */ +/* { dg-options "-Wduplicated-branches" } */ + +unsigned int a, b, c, d, e; +void +fn1 (void) +{ + if (0) /* { dg-warning "this condition has identical branches" } */ + { + if (d > 4294967293) + (void) 5; + c = d; + b = e | a; + } + else + { + if (d > 4294967293) + (void) 5; + c = d; + b = e | a; + } +}