Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / c-c++-common / Wimplicit-fallthrough-10.c
blob99e44d9be7ac5321ed6a7f8a44b2c2a693463025
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wimplicit-fallthrough" } */
5 extern void bar (int);
7 void
8 f (int i)
10 switch (i)
12 case 1:
13 if (i)
15 bar (0);
16 break;
18 else if (i > 10)
20 bar (1);
21 __attribute__((fallthrough));
23 else
24 break;
25 case 2:
26 bar (99);
29 switch (i)
31 case 1:
32 if (i) /* { dg-warning "statement may fall through" } */
33 bar (2);
34 else if (i > 10)
36 bar (3);
37 __attribute__((fallthrough));
39 else
40 break;
41 case 2:
42 bar (4);
45 switch (i)
47 case 1:
48 if (i)
50 bar (0);
51 break;
53 else if (i > 10) /* { dg-warning "statement may fall through" } */
55 bar (1);
57 else
58 break;
59 case 2:
60 bar (99);
63 switch (i)
65 case 1:
66 if (i)
68 bar (0);
69 break;
71 else if (i > 10)
73 bar (1);
74 break;
76 else
77 break;
78 case 2:
79 bar (99);
82 switch (i)
84 case 1:
85 if (i)
87 bar (0);
88 break;
90 else if (i > 10)
92 bar (1);
93 break;
95 else
96 bar (2); /* { dg-warning "statement may fall through" } */
97 case 2:
98 bar (99);
101 switch (i)
103 case 1:
104 if (i)
106 bar (0);
107 __attribute__((fallthrough));
109 else if (i > 10)
111 bar (1);
112 break;
114 else
115 bar (2); /* { dg-warning "statement may fall through" } */
116 case 2:
117 bar (99);
120 switch (i)
122 case 1:
123 if (i)
125 bar (0);
126 __attribute__((fallthrough));
128 else if (i > 10)
130 bar (1);
131 __attribute__((fallthrough));
133 else
134 break;
135 case 2:
136 bar (99);
139 switch (i)
141 case 1:
142 if (i)
144 bar (0);
145 __attribute__((fallthrough));
147 else if (i > 10)
149 bar (1);
150 __attribute__((fallthrough));
152 else
153 bar (2); /* { dg-warning "statement may fall through" } */
154 case 2:
155 bar (99);
158 switch (i)
160 case 1:
161 if (i)
163 bar (0);
164 __attribute__((fallthrough));
166 else if (i > 10) /* { dg-warning "statement may fall through" } */
168 bar (1);
169 bar (2);
171 else
172 __attribute__((fallthrough));
173 case 2:
174 bar (99);
177 switch (i)
179 case 1:
180 if (i) /* { dg-warning "statement may fall through" } */
182 bar (0);
184 else if (i > 10)
186 bar (1);
188 else
190 bar (1);
191 __attribute__((fallthrough));
193 case 2:
194 bar (99);
197 switch (i)
199 case 1:
200 if (i)
202 bar (0);
203 __attribute__((fallthrough));
205 else if (i > 10)
207 bar (1);
208 break;
210 else
212 bar (1);
213 __attribute__((fallthrough));
215 case 2:
216 bar (99);
219 switch (i)
221 case 1:
222 if (i)
224 bar (0);
225 break;
227 else if (i > 10) /* { dg-warning "statement may fall through" } */
229 bar (1);
231 else
233 bar (1);
234 __attribute__((fallthrough));
236 case 2:
237 bar (99);