PR tree-optimization/86401
[official-gcc.git] / gcc / testsuite / c-c++-common / Wlogical-not-parentheses-1.c
blobb6b4e9d37c7ba8188cb3e7724bd465b4911de076
1 /* PR c/77292 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wlogical-not-parentheses" } */
5 /* Test that we don't warn if rhs is a comparison or a logical op. */
7 int
8 foo (int a, int b)
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);
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" } */
25 return r;