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