1 /* { dg-do compile } */
2 /* { dg-options "-Wlogical-not-parentheses" } */
3 
4 /* Test that we don't warn if rhs is 0 and comparison is == or !=.  */
5 
6 #ifndef __cplusplus
7 #define bool _Bool
8 #endif
9 
10 bool r;
11 
12 void
f1(int a)13 f1 (int a)
14 {
15   r = !a == 0;
16   r = !a != 0;
17   r = !a == 1;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
18   r = !a != 1;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
19 }
20 
21 void
f2(int a)22 f2 (int a)
23 {
24   r = !a > 0;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
25   r = !a >= 0;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
26   r = !a < 0;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
27   r = !a <= 0;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
28   r = !a > 1;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
29   r = !a >= 1;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
30   r = !a < 1;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
31   r = !a <= 1;	/* { dg-warning "logical not is only applied to the left hand side of comparison" } */
32 }
33