1 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu99 %s -Wno-unreachable-code
4 goto L
; // expected-error{{cannot jump from this goto statement to its label}}
5 int a
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
6 int b
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
12 goto L
; // expected-error{{cannot jump from this goto statement to its label}}
13 typedef int a
[x
]; // expected-note {{jump bypasses initialization of VLA typedef}}
18 void test3clean(int*);
21 goto L
; // expected-error{{cannot jump from this goto statement to its label}}
22 int a
__attribute((cleanup(test3clean
))); // expected-note {{jump bypasses initialization of variable with __attribute__((cleanup))}}
28 goto L
; // expected-error{{cannot jump from this goto statement to its label}}
29 int a
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
45 // just plain invalid.
46 goto x
; // expected-error {{use of undeclared label 'x'}}
52 int a
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
53 case 2: // expected-error {{cannot jump from switch statement to this case label}}
61 goto L2
; // expected-error {{cannot jump from this goto statement to its label}}
62 for (int arr
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
66 // Statement expressions.
67 goto L3
; // expected-error {{cannot jump from this goto statement to its label}}
68 int Y
= ({ int a
[x
]; // expected-note {{jump bypasses initialization of variable length array}} \
69 // expected-note {{jump enters a statement expression}}
72 goto L4
; // expected-error {{cannot jump from this goto statement to its label}}
74 int A
[x
], // expected-note {{jump bypasses initialization of variable length array}}
75 B
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
81 int A
[x
], B
= ({ if (x
)
92 int A
[x
], B
= ({ if (x
)
95 goto L8
; // expected-error {{cannot jump from this goto statement to its label}}
97 C
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
107 goto L10
; // fixme-error {{cannot jump from this goto statement to its label}}
113 // FIXME: Crashes goto checker.
115 //int A[({ L11: 4; })];
121 int y
= 4; // fixme-warn: skips initializer.
126 // Statement expressions 2.
127 goto L1
; // expected-error {{cannot jump from this goto statement to its label}}
128 return x
== ({ // expected-note {{jump enters a statement expression}}
129 int a
[x
]; // expected-note {{jump bypasses initialization of variable length array}}
134 void test9(int n
, void *P
) {
137 goto *P
; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}}
140 int a
[n
]; // expected-note {{jump bypasses initialization of variable length array}}
142 L3
: // expected-note {{possible target of indirect goto}}
154 void test10(int n
, void *P
) {
155 goto L0
; // expected-error {{cannot jump from this goto statement to its label}}
156 typedef int A
[n
]; // expected-note {{jump bypasses initialization of VLA typedef}}
159 goto L1
; // expected-error {{cannot jump from this goto statement to its label}}
160 A b
, c
[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
162 goto L2
; // expected-error {{cannot jump from this goto statement to its label}}
163 A d
[n
]; // expected-note {{jump bypasses initialization of variable length array}}
174 int Arr
[n
]; // expected-note {{jump bypasses initialization of variable length array}}
175 case 4: // expected-error {{cannot jump from switch statement to this case label}}
182 // TODO: When and if gotos are allowed in blocks, this should work.
189 goto L3
; // expected-error {{cannot jump from this goto statement to its label}}
190 int Arr
[n
]; // expected-note {{jump bypasses initialization of variable length array}}
197 void test13(int n
, void *p
) {
201 static void *ps
[] = { &&a0
};
205 static void *ps
[] = { &&a0
, &&a1
};
219 // PR8473: IR gen can't deal with indirect gotos past VLA
220 // initialization, so that really needs to be a hard error.
221 void test15(int n
, void *pc
) {
222 static const void *addrs
[] = { &&L1
, &&L2
};
224 goto *pc
; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}}
228 char vla
[n
]; // expected-note {{jump bypasses initialization}}
229 L2
: // expected-note {{possible target}}
234 int test16(int [sizeof &&z
]); // expected-error {{use of address-of-label extension outside of a function body}}
238 goto L
; // expected-error {{cannot jump from this goto statement to its label}}
239 (void)sizeof (int){({ L
:; 1; })}; // expected-note {{jump enters a statement expression}}
242 goto M
; // expected-error {{cannot jump from this goto statement to its label}}
243 (void)({ M
:; 1; }); // expected-note {{jump enters a statement expression}}
246 (void)({ goto N
; 1; }); // ok
250 (void)sizeof (int){({ goto O
; 1; })}; // ok (not evaluated)
254 (void)sizeof(({goto P
;}), 0); // expected-error {{cannot jump from this goto statement to its label}}
256 (void)({P
:1;}); // expected-note {{jump enters a statement expression}}