diff options
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/c-common.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr40172.c | 31 |
4 files changed, 46 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dacd274..e855a71 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,7 +1,13 @@ +2009-05-17 Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR c/40172 + * c-common.c (warn_logical_operator): Don't warn if one of + expression isn't always true or false. + 2009-05-17 Kai Tietz <kai.tietz@onevision.com> - * config/i386/biarch32.h: New file. - * config.gcc: Add for target i386-w64-* the biarch32.h to tm_file. + * config/i386/biarch32.h: New file. + * config.gcc: Add for target i386-w64-* the biarch32.h to tm_file. 2009-05-17 Adam Nemet <anemet@caviumnetworks.com> diff --git a/gcc/c-common.c b/gcc/c-common.c index e5c3d0d..fadbdaa 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1784,10 +1784,8 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, in0_p = !in0_p, in1_p = !in1_p; /* If both expressions are the same, if we can merge the ranges, and we - can build the range test, return it or it inverted. If one of the - ranges is always true or always false, consider it to be the same - expression as the other. */ - if ((lhs == 0 || rhs == 0 || operand_equal_p (lhs, rhs, 0)) + can build the range test, return it or it inverted. */ + if (lhs && rhs && operand_equal_p (lhs, rhs, 0) && merge_ranges (&in_p, &low, &high, in0_p, low0, high0, in1_p, low1, high1) && 0 != (tem = build_range_check (type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1494ae9..883f041 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-05-17 H.J. Lu <hongjiu.lu@intel.com> + + PR c/40172 + * gcc.dg/pr40172.c: New. + 2009-05-17 Jason Merrill <jason@redhat.com> PR c++/40139 diff --git a/gcc/testsuite/gcc.dg/pr40172.c b/gcc/testsuite/gcc.dg/pr40172.c new file mode 100644 index 0000000..aff3476 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr40172.c @@ -0,0 +1,31 @@ +/* PR middle-end/40172 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -W -Werror" } */ + +struct rtx_def; +typedef struct rtx_def *rtx; + +extern int foo; +extern int bar; +extern int xxx; + +int +test (void) +{ + if (((rtx) 0 != (rtx) 0) && xxx ? foo : bar) + return 1; + else if ((foo & 0) && xxx) + return 2; + else if (foo & 0) + return 3; + else if (0 && xxx) + return 4; + else if (0) + return 5; + if (((int) 0 != (int) 0) && bar ? foo : xxx) + return 6; + else if (0 != 0 && foo ? xxx : bar) + return 7; + else + return 0; +} |