Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / c-c++-common / Wimplicit-fallthrough-2.c
blob4dfb278c27b30188c3d889522ea48a05b2d6d616
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wimplicit-fallthrough" } */
5 extern void bar (int);
7 /* Test if without else. */
9 void
10 f (int i)
12 switch (i)
14 case 1:
15 if (i) /* { dg-warning "statement may fall through" } */
16 bar (1);
17 case 2:
18 __builtin_abort ();
21 switch (i)
23 case 1:
24 if (i) /* { dg-warning "statement may fall through" } */
25 return;
26 case 2:
27 __builtin_abort ();
30 switch (i)
32 case 1:
33 if (i)
34 bar (1);
35 break;
36 case 2:
37 __builtin_abort ();
40 switch (i)
42 case 1:
43 if (i)
44 return;
45 break;
46 case 2:
47 __builtin_abort ();
50 switch (i)
52 case 1:
53 if (i) /* { dg-warning "statement may fall through" } */
54 goto L1;
55 case 2:
56 L1:
57 __builtin_abort ();
60 switch (i)
62 case 1:
63 if (i) /* { dg-warning "statement may fall through" } */
64 goto L2;
65 L2:
66 case 2:
67 __builtin_abort ();
70 switch (i)
72 case 1:
73 if (i)
74 goto L3;
75 break;
76 case 2:
77 L3:
78 __builtin_abort ();
81 switch (i)
83 case 1:
84 if (i)
85 goto L4;
86 break;
87 L4:
88 case 2:
89 __builtin_abort ();
92 switch (i)
94 case 1:
95 if (i) /* { dg-warning "statement may fall through" } */
96 if (i > 9)
97 bar (1);
98 case 2:
99 __builtin_abort ();
102 switch (i)
104 case 1:
105 if (i)
106 if (i > 9)
107 bar (1);
108 break;
109 case 2:
110 __builtin_abort ();
113 switch (i)
115 case 1:
116 { int a; }
118 if (i) /* { dg-warning "statement may fall through" } */
119 if (i > 9)
120 bar (1);
122 case 2:
123 __builtin_abort ();
126 switch (i)
128 case 1:
129 if (i)
130 bar (1);
131 bar (2); /* { dg-warning "statement may fall through" } */
132 case 2:
133 __builtin_abort ();
136 switch (i)
138 case 1:
139 if (i)
140 bar (1);
141 bar (2);
142 break;
143 case 2:
144 __builtin_abort ();
147 switch (i)
149 case 1:
150 if (i)
151 return;
152 bar (2); /* { dg-warning "statement may fall through" } */
153 case 2:
154 __builtin_abort ();
157 switch (i)
159 case 1:
160 if (i)
161 return;
162 bar (2);
163 break;
164 case 2:
165 __builtin_abort ();
168 switch (i)
170 case 1:
171 if (i)
172 bar (1);
173 if (i)
174 bar (2);
175 if (i)
176 bar (3);
177 bar (4); /* { dg-warning "statement may fall through" } */
178 case 2:
179 __builtin_abort ();
182 switch (i)
184 case 1:
185 if (i)
186 bar (1);
187 if (i)
188 bar (2);
189 if (i) /* { dg-warning "statement may fall through" } */
190 bar (3);
191 case 2:
192 __builtin_abort ();
195 switch (i)
197 case 1:
198 if (i)
199 bar (1);
200 if (i)
201 bar (2);
202 if (i)
203 bar (3);
204 bar (4);
205 break;
206 case 2:
207 __builtin_abort ();
210 switch (i)
212 case 1:
213 if (i)
214 bar (1);
215 if (i)
216 bar (2);
217 if (i)
218 bar (3);
219 break;
220 case 2:
221 __builtin_abort ();