Debian Codegraph @

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

raw
1 /* PR c/7652 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wimplicit-fallthrough" } */
4
5 extern void bar (int);
6 extern int bar2 (void);
7 extern int *map;
8 void
9 f (int i)
10 {
11 switch (i)
12 {
13 case 1:
14 bar (0); /* { dg-warning "statement may fall through" } */
15 static int i = 10;
16 case 2:
17 bar (99);
18 }
19
20 switch (i)
21 {
22 case 1:
23 { /* { dg-warning "statement may fall through" "" { target c } } */
24 int a[i];
25 } /* { dg-warning "statement may fall through" "" { target c++ } } */
26 case 2:
27 bar (99);
28 }
29
30 switch (i)
31 {
32 case 1:
33 for (int j = 0; j < 10; j++) /* { dg-warning "statement may fall through" "" { target c } } */
34 map[j] = j; /* { dg-warning "statement may fall through" "" { target c++ } } */
35 case 2:
36 bar (99);
37 }
38
39 switch (i)
40 {
41 case 1:
42 do
43 bar (2);
44 while (--i); /* { dg-warning "statement may fall through" } */
45 case 2:
46 bar (99);
47 }
48
49 switch (i)
50 {
51 case 1:
52 {
53 switch (i + 2) /* { dg-warning "statement may fall through" } */
54 case 4:
55 bar (1);
56 case 5:
57 bar (5);
58 return;
59 }
60 case 2:
61 bar (99);
62 }
63
64 switch (i)
65 {
66 case 1:;
67 case 2:;
68 }
69
70 switch (i)
71 {
72 }
73
74 switch (i)
75 {
76 case 1:
77 if (i & 1) /* { dg-warning "statement may fall through" } */
78 {
79 bar (23);
80 break;
81 }
82 case 2:
83 bar (99);
84 }
85
86 switch (i)
87 {
88 case 1:
89 if (i > 9) /* { dg-warning "statement may fall through" } */
90 {
91 bar (9);
92 if (i == 10)
93 {
94 bar (10);
95 break;
96 }
97 }
98 case 2:
99 bar (99);
100 }
101
102 int r;
103 switch (i)
104 {
105 case 1:
106 r = bar2 ();
107 if (r) /* { dg-warning "statement may fall through" } */
108 break;
109 case 2:
110 bar (99);
111 }
112
113 switch (i)
114 {
115 case 1:
116 r = bar2 ();
117 if (r)
118 return;
119 if (!i) /* { dg-warning "statement may fall through" } */
120 return;
121 case 2:
122 bar (99);
123 }
124 }