| 1 |
/* PR c/77292 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-Wlogical-not-parentheses" } */ |
| 4 |
|
| 5 |
/* Test that we don't warn if rhs is a comparison or a logical op. */ |
| 6 |
|
| 7 |
int |
| 8 |
foo (int a, int b) |
| 9 |
{ |
| 10 |
int r = 0; |
| 11 |
r += !a == (a < b); |
| 12 |
r += !a == (a > b); |
| 13 |
r += !a == (a >= b); |
| 14 |
r += !a == (a <= b); |
| 15 |
r += !a == (a != b); |
| 16 |
r += !a == (a == b); |
| 17 |
r += !a == (a || b); |
| 18 |
r += !a == (a && b); |
| 19 |
r += !a == (!b); |
| 20 |
|
| 21 |
r += !a == (a ^ b); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ |
| 22 |
r += !a == (a | b); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ |
| 23 |
r += !a == (a & b); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ |
| 24 |
|
| 25 |
return r; |
| 26 |
} |