1 /* { dg-do compile } */
2 /* { dg-options "-Wimplicit-fallthrough" } */
3
4 void bar (int);
5
6 void
foo(int i)7 foo (int i)
8 {
9 switch (i)
10 {
11 case 1:
12 bar (1); /* { dg-bogus "this statement may \[laf]* through" } */
13 /* FALLTHROUGH */
14 case 2:
15 bar (2);
16 break;
17 case 3:
18 bar (3); /* { dg-bogus "this statement may \[laf]* through" } */
19 /* FALLS THRU. */
20 /* Some other comment. */
21 case 4:
22 bar (4);
23 break;
24 case 5:
25 bar (5); /* { dg-bogus "this statement may \[laf]* through" } */
26 /* Else Fall-Thru! */
27 case 6:
28 bar (6);
29 break;
30 case 7:
31 bar (7); /* { dg-bogus "this statement may \[laf]* through" } */
32 /* Some comment. */
33 /* ... fallthrough ... */
34 /* Some other comment. */
35 /* And yet another. */
36 case 8:
37 bar (8);
38 break;
39 case 9:
40 bar (9); /* { dg-bogus "this statement may \[laf]* through" } */
41 /* Intentional Fallthru */
42 case 10:
43 bar (10);
44 break;
45 case 11:
46 bar (11); /* { dg-bogus "this statement may \[laf]* through" } */
47 /* intentionally fall through */
48 case 12:
49 bar (12);
50 break;
51 case 13:
52 bar (13); /* { dg-bogus "this statement may \[laf]* through" } */
53 /* Falls Through - for reasons known only to the author. */
54 case 14:
55 bar (14);
56 break;
57 case 15:
58 bar (15); /* { dg-bogus "this statement may \[laf]* through" } */
59 /*-fallthrough*/
60 case 16:
61 bar (16);
62 break;
63 case 17:
64 bar (17); /* { dg-bogus "this statement may \[laf]* through" } */
65 /*@fallthrough@*/
66 case 18:
67 bar (18);
68 break;
69 case 19:
70 bar (19); /* { dg-bogus "this statement may \[laf]* through" } */
71 /*lint -fallthrough*/
72 case 20:
73 bar (20);
74 break;
75 case 21:
76 bar (21); /* { dg-bogus "this statement may \[laf]* through" } */
77 /*lint -fallthrough */
78 case 22:
79 bar (22);
80 break;
81 case 23:
82 bar (23); /* { dg-bogus "this statement may \[laf]* through" } */
83 /*fallthru*/
84 case 24:
85 bar (24);
86 break;
87 case 25:
88 bar (25); /* { dg-bogus "this statement may \[laf]* through" } */
89 /*Else fallthru*/
90 case 26:
91 bar (26);
92 break;
93 case 27:
94 bar (27); /* { dg-bogus "this statement may \[laf]* through" } */
95 /*Intentional fallthru*/
96 case 28:
97 bar (28);
98 break;
99 case 29:
100 bar (29); /* { dg-bogus "this statement may \[laf]* through" } */
101 /*Intentionally fallthru*/
102 case 30:
103 bar (30);
104 break;
105 case 31:
106 bar (31); /* { dg-bogus "this statement may \[laf]* through" } */
107 /*Falls thru*/
108 case 32:
109 bar (32);
110 break;
111 case 33:
112 bar (33); /* { dg-bogus "this statement may \[laf]* through" } */
113 /*Fall-through*/
114 case 34:
115 bar (34);
116 break;
117 case 35:
118 bar (35); /* { dg-bogus "this statement may \[laf]* through" } */
119 /* Else, fall-through. */
120 case 36:
121 bar (36);
122 break;
123 default:
124 break;
125 }
126 switch (i)
127 {
128 case 1:
129 bar (1); /* { dg-bogus "this statement may \[laf]* through" } */
130 // FALLTHROUGH
131 case 2:
132 bar (2);
133 break;
134 case 3:
135 bar (3); /* { dg-bogus "this statement may \[laf]* through" } */
136 // FALLS THRU.
137 // Some other comment.
138 case 4:
139 bar (4);
140 break;
141 case 5:
142 bar (5); /* { dg-bogus "this statement may \[laf]* through" } */
143 // Else Fall-Thru!
144 case 6:
145 bar (6);
146 break;
147 case 7:
148 bar (7); /* { dg-bogus "this statement may \[laf]* through" } */
149 // Some comment.
150 // ... fallthrough ...
151 // Some other comment.
152 // And yet another.
153 case 8:
154 bar (8);
155 break;
156 case 9:
157 bar (9); /* { dg-bogus "this statement may \[laf]* through" } */
158 // Intentional Fallthru
159 case 10:
160 bar (10);
161 break;
162 case 11:
163 bar (11); /* { dg-bogus "this statement may \[laf]* through" } */
164 // intentionally fall through
165 case 12:
166 bar (12);
167 break;
168 case 13:
169 bar (13); /* { dg-bogus "this statement may \[laf]* through" } */
170 // Falls Through - for reasons known only to the author.
171 case 14:
172 bar (14);
173 break;
174 case 15:
175 bar (15); /* { dg-bogus "this statement may \[laf]* through" } */
176 //-fallthrough
177 case 16:
178 bar (16);
179 break;
180 case 17:
181 bar (17); /* { dg-bogus "this statement may \[laf]* through" } */
182 //@fallthrough@
183 case 18:
184 bar (18);
185 break;
186 case 19:
187 bar (19); /* { dg-bogus "this statement may \[laf]* through" } */
188 //lint -fallthrough
189 case 20:
190 bar (20);
191 break;
192 case 21:
193 bar (21); /* { dg-bogus "this statement may \[laf]* through" } */
194 //lint -fallthrough
195 case 22:
196 bar (22);
197 break;
198 case 23:
199 bar (23); /* { dg-bogus "this statement may \[laf]* through" } */
200 //fallthru
201 case 24:
202 bar (24);
203 break;
204 case 25:
205 bar (25); /* { dg-bogus "this statement may \[laf]* through" } */
206 //Else fallthru
207 case 26:
208 bar (26);
209 break;
210 case 27:
211 bar (27); /* { dg-bogus "this statement may \[laf]* through" } */
212 //Intentional fallthru
213 case 28:
214 bar (28);
215 break;
216 case 29:
217 bar (29); /* { dg-bogus "this statement may \[laf]* through" } */
218 //Intentionally fallthru
219 case 30:
220 bar (30);
221 break;
222 case 31:
223 bar (31); /* { dg-bogus "this statement may \[laf]* through" } */
224 //Falls thru
225 case 32:
226 bar (32);
227 break;
228 case 33:
229 bar (33); /* { dg-bogus "this statement may \[laf]* through" } */
230 //Fall-through
231 case 34:
232 bar (34);
233 break;
234 case 35:
235 bar (35); /* { dg-bogus "this statement may \[laf]* through" } */
236 // Else, fall-through
237 case 36:
238 bar (36);
239 break;
240 default:
241 break;
242 }
243 }
244