Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / Wtautological-compare-5.c
blob4664bfdeae63af2fba4fc8c17d9c56d6aec2935b
1 /* PR c/81783 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wtautological-compare" } */
5 enum E { FOO = 128 };
7 int
8 f (int a)
10 if ((a & 16) == 10) /* { dg-warning "bitwise comparison always evaluates to false" } */
11 return 1;
12 if ((16 & a) == 10) /* { dg-warning "bitwise comparison always evaluates to false" } */
13 return 1;
14 if (10 == (a & 16)) /* { dg-warning "bitwise comparison always evaluates to false" } */
15 return 1;
16 if (10 == (16 & a)) /* { dg-warning "bitwise comparison always evaluates to false" } */
17 return 1;
19 if ((a & 16) != 10) /* { dg-warning "bitwise comparison always evaluates to true" } */
20 return 1;
21 if ((16 & a) != 10) /* { dg-warning "bitwise comparison always evaluates to true" } */
22 return 1;
23 if (10 != (a & 16)) /* { dg-warning "bitwise comparison always evaluates to true" } */
24 return 1;
25 if (10 != (16 & a)) /* { dg-warning "bitwise comparison always evaluates to true" } */
26 return 1;
28 if ((a & 9) == 8)
29 return 1;
30 if ((9 & a) == 8)
31 return 1;
32 if (8 == (a & 9))
33 return 1;
34 if (8 == (9 & a))
35 return 1;
37 if ((a & 9) != 8)
38 return 1;
39 if ((9 & a) != 8)
40 return 1;
41 if (8 != (a & 9))
42 return 1;
43 if (8 != (9 & a))
44 return 1;
46 if ((a | 16) == 10) /* { dg-warning "bitwise comparison always evaluates to false" } */
47 return 1;
48 if ((16 | a) == 10) /* { dg-warning "bitwise comparison always evaluates to false" } */
49 return 1;
50 if (10 == (a | 16)) /* { dg-warning "bitwise comparison always evaluates to false" } */
51 return 1;
52 if (10 == (16 | a)) /* { dg-warning "bitwise comparison always evaluates to false" } */
53 return 1;
55 if ((a | 16) != 10) /* { dg-warning "bitwise comparison always evaluates to true" } */
56 return 1;
57 if ((16 | a) != 10) /* { dg-warning "bitwise comparison always evaluates to true" } */
58 return 1;
59 if (10 != (a | 16)) /* { dg-warning "bitwise comparison always evaluates to true" } */
60 return 1;
61 if (10 != (16 | a)) /* { dg-warning "bitwise comparison always evaluates to true" } */
62 return 1;
64 if ((a | 9) == 8) /* { dg-warning "bitwise comparison always evaluates to false" } */
65 return 1;
66 if ((9 | a) == 8) /* { dg-warning "bitwise comparison always evaluates to false" } */
67 return 1;
68 if (8 == (a | 9)) /* { dg-warning "bitwise comparison always evaluates to false" } */
69 return 1;
70 if (8 == (9 | a)) /* { dg-warning "bitwise comparison always evaluates to false" } */
71 return 1;
73 if ((a | 9) != 8) /* { dg-warning "bitwise comparison always evaluates to true" } */
74 return 1;
75 if ((9 | a) != 8) /* { dg-warning "bitwise comparison always evaluates to true" } */
76 return 1;
77 if (8 != (a | 9)) /* { dg-warning "bitwise comparison always evaluates to true" } */
78 return 1;
79 if (8 != (9 | a)) /* { dg-warning "bitwise comparison always evaluates to true" } */
80 return 1;
82 if ((a & 128) != 1) /* { dg-warning "bitwise comparison always evaluates to true" } */
83 return 1;
84 if ((128 & a) != 1) /* { dg-warning "bitwise comparison always evaluates to true" } */
85 return 1;
86 if ((a & FOO) != 1) /* { dg-warning "bitwise comparison always evaluates to true" } */
87 return 1;
88 if ((FOO & a) != 1) /* { dg-warning "bitwise comparison always evaluates to true" } */
89 return 1;
90 if ((a & 128) == 1) /* { dg-warning "bitwise comparison always evaluates to false" } */
91 return 1;
92 if ((128 & a) == 1) /* { dg-warning "bitwise comparison always evaluates to false" } */
93 return 1;
94 if ((a & FOO) == 1) /* { dg-warning "bitwise comparison always evaluates to false" } */
95 return 1;
96 if ((FOO & a) == 1) /* { dg-warning "bitwise comparison always evaluates to false" } */
97 return 1;
99 #define N 0x10
100 if ((a & N) == 10) /* { dg-bogus "bitwise comparison always evaluates to false" "" { xfail *-*-* } } */
101 return 1;
102 if ((a | N) == 10) /* { dg-bogus "bitwise comparison always evaluates to false" "" { xfail *-*-* } } */
103 return 1;
105 return 0;