blob: 98662be621bcabae47c6ea9dc272759725ced3bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// RUN: clang-cc -fsyntax-only -verify -std=gnu99 %s
int test1(int x) {
goto L; // expected-error{{illegal goto into protected scope}}
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
int b[x]; // expected-note {{jump bypasses initialization of variable length array}}
L:
return sizeof a;
}
int test2(int x) {
goto L; // expected-error{{illegal goto into protected scope}}
typedef int a[x]; // expected-note {{jump bypasses initialization of VLA typedef}}
L:
return sizeof(a);
}
void test3clean(int*);
int test3() {
goto L; // expected-error{{illegal goto into protected scope}}
int a __attribute((cleanup(test3clean))); // expected-note {{jump bypasses initialization of declaration with __attribute__((cleanup))}}
L:
return a;
}
int test4(int x) {
goto L; // expected-error{{illegal goto into protected scope}}
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
test4(x);
L:
return sizeof a;
}
int test5(int x) {
int a[x];
test5(x);
goto L; // Ok.
L:
goto L; // Ok.
return sizeof a;
}
int test6() {
// just plain invalid.
goto x; // expected-error {{use of undeclared label 'x'}}
}
void test7(int x) {
switch (x) {
case 1: ;
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
case 2: // expected-error {{illegal switch case into protected scope}}
a[1] = 2;
break;
}
}
int test8(int x) {
// For statement.
goto L2; // expected-error {{illegal goto into protected scope}}
for (int arr[x]; // expected-note {{jump bypasses initialization of variable length array}}
; ++x)
L2:;
// Statement expressions.
goto L3; // expected-error {{illegal goto into protected scope}}
int Y = ({ int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
L3: 4; });
goto L4; // expected-error {{illegal goto into protected scope}}
{
int A[x], // expected-note {{jump bypasses initialization of variable length array}}
B[x]; // expected-note {{jump bypasses initialization of variable length array}}
L4: ;
}
{
L5: ;// ok
int A[x], B = ({ if (x)
goto L5;
else
goto L6;
4; });
L6:; // ok.
}
{
L7: ;// ok
int A[x], B = ({ if (x)
goto L7;
else
goto L8; // expected-error {{illegal goto into protected scope}}
4; }),
C[x]; // expected-note {{jump bypasses initialization of variable length array}}
L8:; // bad
}
{
L9: ;// ok
int A[({ if (x)
goto L9;
else
// FIXME:
goto L10; // fixme-error {{illegal goto into protected scope}}
4; })];
L10:; // bad
}
{
// FIXME: Crashes goto checker.
//goto L11;// ok
//int A[({ L11: 4; })];
}
// Statement expressions 2.
goto L1; // expected-error {{illegal goto into protected scope}}
return x == ({
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
L1:
42; });
}
|