Debian Codegraph @

gcc/testsuite/c-c++-common/Wimplicit-fallthrough-10.c

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