]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/c-c++-common/Wimplicit-fallthrough-6.c
Implement -Wimplicit-fallthrough.
[gcc.git] / gcc / testsuite / c-c++-common / Wimplicit-fallthrough-6.c
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wimplicit-fallthrough" } */
4
5 extern void bar (int);
6
7 /* Test nested scopes. */
8
9 void
10 f (int i)
11 {
12 switch (i)
13 {
14 case 1:
15 {
16 int j;
17 }
18 case 2:
19 bar (99);
20 }
21
22 switch (i)
23 {
24 case 1:
25 {
26 int j = 10; /* { dg-warning "statement may fall through" } */
27 }
28 case 2:
29 bar (99);
30 }
31
32 switch (i)
33 {
34 case 1:
35 {
36 int k = 9;
37 k++;
38 {
39 int j = 10;
40 j++; /* { dg-warning "statement may fall through" } */
41 }
42 }
43 case 2:
44 bar (99);
45 }
46
47 switch (i)
48 {
49 case 1:
50 {
51 int k = 9;
52 k++;
53 {
54 int j = 10;
55 j++;
56 {
57 bar (1); /* { dg-warning "statement may fall through" } */
58 }
59 }
60 }
61 case 2:
62 bar (99);
63 }
64
65 switch (i)
66 {
67 case 1:
68 {
69 int j = 0;
70 bar (j);
71 __attribute__((fallthrough));
72 }
73 case 2:
74 bar (99);
75 }
76
77 switch (i)
78 {
79 case 1:
80 {
81 int j = 0;
82 {
83 int k = j + 5;
84 bar (k);
85 __attribute__((fallthrough));
86 }
87 }
88 case 2:
89 bar (99);
90 }
91
92 switch (i)
93 {
94 case 1:
95 {
96 int j = 0;
97 bar (j);
98 return;
99 }
100 case 2:
101 bar (99);
102 }
103
104 switch (i)
105 {
106 case 1:
107 {
108 int j = 0;
109 bar (j);
110 goto L1;
111 }
112 L1:
113 case 2:
114 bar (99);
115 }
116
117 switch (i)
118 {
119 case 1:
120 { /* { dg-warning "statement may fall through" "" { target c } 120 } */
121 int j = 0;
122 bar (j);
123 if (j == 8)
124 return; /* { dg-warning "statement may fall through" "" { target c++ } 124 } */
125 }
126 case 2:
127 bar (99);
128 }
129
130 switch (i)
131 {
132 case 1:
133 {
134 int j = 0;
135 bar (j);
136 if (j == 8)
137 return;
138 else
139 return;
140 }
141 case 2:
142 bar (99);
143 }
144
145 switch (i)
146 {
147 case 1:
148 { /* { dg-warning "statement may fall through" "" { target c } 148 } */
149 int j = 0;
150 bar (j);
151 if (j == 8)
152 bar (1);
153 else
154 return; /* { dg-warning "statement may fall through" "" { target c++ } 154 } */
155 }
156 case 2:
157 bar (99);
158 }
159
160 switch (i)
161 {
162 case 1:
163 {
164 int j = 0;
165 bar (j);
166 if (j == 8)
167 return;
168 else
169 bar (2); /* { dg-warning "statement may fall through" } */
170 }
171 case 2:
172 bar (99);
173 }
174
175 switch (i)
176 {
177 case 1:
178 { /* { dg-warning "statement may fall through" "" { target c } 178 } */
179 int j = 0;
180 bar (j);
181 if (j == 8)
182 bar (1);
183 else
184 bar (2); /* { dg-warning "statement may fall through" "" { target c++ } 184 } */
185 }
186 case 2:
187 bar (99);
188 }
189
190 switch (i)
191 {
192 case 1:
193 {
194 int j = 0;
195 bar (j);
196 if (j == 8)
197 return;
198 }
199 break;
200 case 2:
201 bar (99);
202 }
203
204 switch (i)
205 {
206 case 1:
207 {
208 int j = 0;
209 bar (j);
210 if (j == 8)
211 return;
212 else
213 return;
214 }
215 break;
216 case 2:
217 bar (99);
218 }
219
220 switch (i)
221 {
222 case 1:
223 {
224 int j = 0;
225 bar (j);
226 if (j == 8)
227 bar (1);
228 else
229 return;
230 }
231 break;
232 case 2:
233 bar (99);
234 }
235
236 switch (i)
237 {
238 case 1:
239 {
240 int j = 0;
241 bar (j);
242 if (j == 8)
243 return;
244 else
245 bar (2);
246 }
247 break;
248 case 2:
249 bar (99);
250 }
251
252 switch (i)
253 {
254 case 1:
255 {
256 int j = 0;
257 bar (j);
258 if (j == 8)
259 bar (1);
260 else
261 bar (2);
262 }
263 break;
264 case 2:
265 bar (99);
266 }
267
268 switch (i)
269 {
270 case 1:
271 {
272 int j = 9;
273 while (1);
274 }
275 case 2:
276 bar (99);
277 }
278
279 switch (i)
280 {
281 case 1:
282 { /* { dg-warning "statement may fall through" "" { target c } 282 } */
283 int j = 9;
284 switch (j); /* { dg-warning "statement may fall through" "" { target c++ } 284 } */
285 }
286 case 2:
287 bar (99);
288 }
289
290 switch (i)
291 {
292 case 1:
293 {
294 int j = 0;
295 bar (j);
296 if (j == 8)
297 bar (1);
298 else
299 bar (2);
300 __attribute__((fallthrough));
301 }
302 case 2:
303 bar (99);
304 }
305 }
This page took 0.052018 seconds and 5 git commands to generate.