PR tree-optimization/86401
[official-gcc.git] / gcc / testsuite / c-c++-common / pr60439.c
blobdc12d1fd272780c3a35bdf8745015db17b3d3da3
1 /* PR c/60439 */
2 /* { dg-do compile } */
3 /* { dg-prune-output "case label value exceeds" } */
5 #ifndef __cplusplus
6 # define bool _Bool
7 #endif
9 extern bool foo (void);
11 void
12 f1 (bool b)
14 switch (b) /* { dg-warning "switch condition has" } */
16 case 3:
17 break;
21 void
22 f2 (int a, int b)
24 switch (a && b) /* { dg-warning "switch condition has" } */
26 case 3:
27 break;
29 switch ((bool) (a && b)) /* { dg-warning "switch condition has" } */
31 case 3:
32 break;
34 switch ((a && b) || a) /* { dg-warning "switch condition has" } */
36 case 3:
37 break;
39 /* No warnings on following. */
40 switch ((int) (a && b))
41 break;
42 switch ((unsigned int) (a && b))
43 break;
44 switch ((unsigned short int) (a && b))
45 break;
46 switch ((char) (a && b))
47 break;
50 void
51 f3 (int a)
53 switch (!!a) /* { dg-warning "switch condition has" } */
55 case 3:
56 break;
58 switch (!a) /* { dg-warning "switch condition has" } */
60 case 3:
61 break;
65 void
66 f4 (void)
68 switch (foo ()) /* { dg-warning "switch condition has" } */
70 case 3:
71 break;
75 void
76 f5 (int a)
78 switch (a == 3) /* { dg-warning "switch condition has" } */
80 case 3:
81 break;
83 switch (a != 3) /* { dg-warning "switch condition has" } */
85 case 3:
86 break;
88 switch (a > 3) /* { dg-warning "switch condition has" } */
90 case 3:
91 break;
93 switch (a < 3) /* { dg-warning "switch condition has" } */
95 case 3:
96 break;
98 switch (a <= 3) /* { dg-warning "switch condition has" } */
100 case 3:
101 break;
103 switch (a >= 3) /* { dg-warning "switch condition has" } */
105 case 3:
106 break;
108 switch (foo (), foo (), a >= 42) /* { dg-warning "switch condition has" } */
110 case 3:
111 break;
113 switch (a == 3, a & 4, a ^ 5, a)
114 break;
115 switch ((int) (a == 3))
116 break;
117 switch ((int) (a != 3))
118 break;
121 void
122 f6 (bool b)
124 switch (b) /* { dg-warning "switch condition has" } */
126 case 3:
127 break;
129 switch (!b) /* { dg-warning "switch condition has" } */
131 case 3:
132 break;
136 void
137 f7 (void)
139 bool b;
140 switch (b = 1) /* { dg-warning "switch condition has" } */
142 case 3:
143 break;
147 void
148 f8 (int i)
150 switch (i)
151 break;
152 switch ((int) i)
153 break;
154 switch ((unsigned int) i)
155 break;
156 switch ((bool) i) /* { dg-warning "switch condition has" } */
158 case 11:
159 break;