2 /* { dg-do compile } */
3 /* { dg-options "-Wall" } */
11 extern bool foo (void);
19 r
= b
== 2; /* { dg-warning "with boolean expression is always false" } */
20 r
= b
!= 2; /* { dg-warning "with boolean expression is always true" } */
21 r
= b
< 2; /* { dg-warning "with boolean expression is always true" } */
22 r
= b
> 2; /* { dg-warning "with boolean expression is always false" } */
23 r
= b
<= 2; /* { dg-warning "with boolean expression is always true" } */
24 r
= b
>= 2; /* { dg-warning "with boolean expression is always false" } */
26 r
= b
== -1; /* { dg-warning "with boolean expression is always false" } */
27 r
= b
!= -1; /* { dg-warning "with boolean expression is always true" } */
28 r
= b
< -1; /* { dg-warning "with boolean expression is always false" } */
29 r
= b
> -1; /* { dg-warning "with boolean expression is always true" } */
30 r
= b
<= -1; /* { dg-warning "with boolean expression is always false" } */
31 r
= b
>= -1; /* { dg-warning "with boolean expression is always true" } */
33 r
= foo () == 2; /* { dg-warning "with boolean expression is always false" } */
34 r
= foo () != 2; /* { dg-warning "with boolean expression is always true" } */
35 r
= foo () < 2; /* { dg-warning "with boolean expression is always true" } */
36 r
= foo () > 2; /* { dg-warning "with boolean expression is always false" } */
37 r
= foo () <= 2; /* { dg-warning "with boolean expression is always true" } */
38 r
= foo () >= 2; /* { dg-warning "with boolean expression is always false" } */
40 r
= b
== E
; /* { dg-warning "with boolean expression is always false" } */
41 r
= b
!= E
; /* { dg-warning "with boolean expression is always true" } */
42 r
= b
< E
; /* { dg-warning "with boolean expression is always true" } */
43 r
= b
> E
; /* { dg-warning "with boolean expression is always false" } */
44 r
= b
<= E
; /* { dg-warning "with boolean expression is always true" } */
45 r
= b
>= E
; /* { dg-warning "with boolean expression is always false" } */
47 /* Swap LHS and RHS. */
48 r
= 2 == b
; /* { dg-warning "with boolean expression is always false" } */
49 r
= 2 != b
; /* { dg-warning "with boolean expression is always true" } */
50 r
= 2 < b
; /* { dg-warning "with boolean expression is always false" } */
51 r
= 2 > b
; /* { dg-warning "with boolean expression is always true" } */
52 r
= 2 <= b
; /* { dg-warning "with boolean expression is always false" } */
53 r
= 2 >= b
; /* { dg-warning "with boolean expression is always true" } */
55 r
= -1 == b
; /* { dg-warning "with boolean expression is always false" } */
56 r
= -1 != b
; /* { dg-warning "with boolean expression is always true" } */
57 r
= -1 < b
; /* { dg-warning "with boolean expression is always true" } */
58 r
= -1 > b
; /* { dg-warning "with boolean expression is always false" } */
59 r
= -1 <= b
; /* { dg-warning "with boolean expression is always true" } */
60 r
= -1 >= b
; /* { dg-warning "with boolean expression is always false" } */
62 r
= E
== b
; /* { dg-warning "with boolean expression is always false" } */
63 r
= E
!= b
; /* { dg-warning "with boolean expression is always true" } */
64 r
= E
< b
; /* { dg-warning "with boolean expression is always false" } */
65 r
= E
> b
; /* { dg-warning "with boolean expression is always true" } */
66 r
= E
<= b
; /* { dg-warning "with boolean expression is always false" } */
67 r
= E
>= b
; /* { dg-warning "with boolean expression is always true" } */
69 /* These are of course fine. */
84 r
= (i1
== i2
) == 2; /* { dg-warning "with boolean expression is always false" } */
85 r
= (i1
== i2
) != 2; /* { dg-warning "with boolean expression is always true" } */
86 r
= (i1
== i2
) < 2; /* { dg-warning "with boolean expression is always true" } */
87 r
= (i1
== i2
) > 2; /* { dg-warning "with boolean expression is always false" } */
88 r
= (i1
== i2
) <= 2; /* { dg-warning "with boolean expression is always true" } */
89 r
= (i1
== i2
) >= 2; /* { dg-warning "with boolean expression is always false" } */
91 r
= (i1
== i2
) == -1; /* { dg-warning "with boolean expression is always false" } */
92 r
= (i1
== i2
) != -1; /* { dg-warning "with boolean expression is always true" } */
93 r
= (i1
== i2
) < -1; /* { dg-warning "with boolean expression is always false" } */
94 r
= (i1
== i2
) > -1; /* { dg-warning "with boolean expression is always true" } */
95 r
= (i1
== i2
) <= -1; /* { dg-warning "with boolean expression is always false" } */
96 r
= (i1
== i2
) >= -1; /* { dg-warning "with boolean expression is always true" } */
98 r
= (i1
== i2
) == E
; /* { dg-warning "with boolean expression is always false" } */
99 r
= (i1
== i2
) != E
; /* { dg-warning "with boolean expression is always true" } */
100 r
= (i1
== i2
) < E
; /* { dg-warning "with boolean expression is always true" } */
101 r
= (i1
== i2
) > E
; /* { dg-warning "with boolean expression is always false" } */
102 r
= (i1
== i2
) <= E
; /* { dg-warning "with boolean expression is always true" } */
103 r
= (i1
== i2
) >= E
; /* { dg-warning "with boolean expression is always false" } */
109 /* Don't warn here. */