2012-04-07 02:12:22 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
|
2009-04-15 04:53:38 +08:00
|
|
|
|
|
|
|
@class A, B, C;
|
|
|
|
|
2009-04-18 17:36:27 +08:00
|
|
|
void test1() {
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L; // expected-error{{cannot jump}}
|
|
|
|
goto L2; // expected-error{{cannot jump}}
|
|
|
|
goto L3; // expected-error{{cannot jump}}
|
2009-04-19 05:28:52 +08:00
|
|
|
@try { // expected-note {{jump bypasses initialization of @try block}}
|
2009-04-15 04:53:38 +08:00
|
|
|
L: ;
|
2009-04-19 05:28:52 +08:00
|
|
|
} @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
|
2009-04-15 04:53:38 +08:00
|
|
|
L2: ;
|
|
|
|
} @catch (B *x) {
|
|
|
|
} @catch (C *c) {
|
2009-04-19 05:28:52 +08:00
|
|
|
} @finally {// expected-note {{jump bypasses initialization of @finally block}}
|
2009-04-15 04:53:38 +08:00
|
|
|
L3: ;
|
|
|
|
}
|
2009-04-19 05:28:52 +08:00
|
|
|
|
|
|
|
@try {
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L4; // expected-error{{cannot jump}}
|
|
|
|
goto L5; // expected-error{{cannot jump}}
|
2009-04-19 05:28:52 +08:00
|
|
|
} @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
|
|
|
|
L5: ;
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L6; // expected-error{{cannot jump}}
|
2009-04-19 05:28:52 +08:00
|
|
|
} @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
|
|
|
|
L6: ;
|
|
|
|
} @finally { // expected-note {{jump bypasses initialization of @finally block}}
|
|
|
|
L4: ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@try { // expected-note 2 {{jump bypasses initialization of @try block}}
|
|
|
|
L7: ;
|
|
|
|
} @catch (C *c) {
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L7; // expected-error{{cannot jump}}
|
2009-04-19 05:28:52 +08:00
|
|
|
} @finally {
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L7; // expected-error{{cannot jump}}
|
2009-04-19 05:28:52 +08:00
|
|
|
}
|
|
|
|
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L8; // expected-error{{cannot jump}}
|
2009-04-19 05:28:52 +08:00
|
|
|
@try {
|
2009-04-19 06:35:34 +08:00
|
|
|
} @catch (A *c) {
|
|
|
|
} @catch (B *c) {
|
2009-04-19 05:28:52 +08:00
|
|
|
} @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
|
|
|
|
L8: ;
|
|
|
|
}
|
2009-04-21 14:01:00 +08:00
|
|
|
|
|
|
|
// rdar://6810106
|
|
|
|
id X;
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L9; // expected-error{{cannot jump}}
|
2009-04-21 14:01:00 +08:00
|
|
|
goto L10; // ok
|
|
|
|
@synchronized // expected-note {{jump bypasses initialization of @synchronized block}}
|
|
|
|
( ({ L10: ; X; })) {
|
|
|
|
L9:
|
|
|
|
;
|
|
|
|
}
|
2009-04-15 04:53:38 +08:00
|
|
|
}
|
2009-04-15 22:38:36 +08:00
|
|
|
|
2009-04-18 17:36:27 +08:00
|
|
|
void test2(int a) {
|
2009-04-15 22:38:36 +08:00
|
|
|
if (a) goto L0;
|
|
|
|
@try {} @finally {}
|
|
|
|
L0:
|
|
|
|
return;
|
|
|
|
}
|
2009-04-18 17:36:27 +08:00
|
|
|
|
|
|
|
// rdar://6803963
|
|
|
|
void test3() {
|
|
|
|
@try {
|
|
|
|
goto blargh;
|
|
|
|
blargh: ;
|
|
|
|
} @catch (...) {}
|
|
|
|
}
|
2009-04-19 06:37:38 +08:00
|
|
|
|
|
|
|
@interface Greeter
|
|
|
|
+ (void) hello;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Greeter
|
|
|
|
+ (void) hello {
|
|
|
|
|
|
|
|
@try {
|
2014-09-06 08:24:58 +08:00
|
|
|
goto blargh; // expected-error {{cannot jump}}
|
2009-04-19 06:37:38 +08:00
|
|
|
} @catch (...) { // expected-note {{jump bypasses initialization of @catch block}}
|
|
|
|
blargh: ;
|
|
|
|
}
|
|
|
|
}
|
2009-04-19 13:20:37 +08:00
|
|
|
|
|
|
|
+ (void)meth2 {
|
|
|
|
int n; void *P;
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L0; // expected-error {{cannot jump}}
|
2009-04-19 13:20:37 +08:00
|
|
|
typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}}
|
|
|
|
L0:
|
|
|
|
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L1; // expected-error {{cannot jump}}
|
2009-04-19 13:20:37 +08:00
|
|
|
A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
|
|
|
|
L1:
|
2014-09-06 08:24:58 +08:00
|
|
|
goto L2; // expected-error {{cannot jump}}
|
2009-04-19 13:20:37 +08:00
|
|
|
A d[n]; // expected-note {{jump bypasses initialization of variable length array}}
|
|
|
|
L2:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-19 06:37:38 +08:00
|
|
|
@end
|