1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s 2*67e74705SXin Li 3*67e74705SXin Li@class A, B, C; 4*67e74705SXin Li 5*67e74705SXin Livoid test1() { 6*67e74705SXin Li goto L; // expected-error{{cannot jump}} 7*67e74705SXin Li goto L2; // expected-error{{cannot jump}} 8*67e74705SXin Li goto L3; // expected-error{{cannot jump}} 9*67e74705SXin Li @try { // expected-note {{jump bypasses initialization of @try block}} 10*67e74705SXin LiL: ; 11*67e74705SXin Li } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}} 12*67e74705SXin LiL2: ; 13*67e74705SXin Li } @catch (B *x) { 14*67e74705SXin Li } @catch (C *c) { 15*67e74705SXin Li } @finally {// expected-note {{jump bypasses initialization of @finally block}} 16*67e74705SXin LiL3: ; 17*67e74705SXin Li } 18*67e74705SXin Li 19*67e74705SXin Li @try { 20*67e74705SXin Li goto L4; // expected-error{{cannot jump}} 21*67e74705SXin Li goto L5; // expected-error{{cannot jump}} 22*67e74705SXin Li } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}} 23*67e74705SXin Li L5: ; 24*67e74705SXin Li goto L6; // expected-error{{cannot jump}} 25*67e74705SXin Li } @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}} 26*67e74705SXin Li L6: ; 27*67e74705SXin Li } @finally { // expected-note {{jump bypasses initialization of @finally block}} 28*67e74705SXin Li L4: ; 29*67e74705SXin Li } 30*67e74705SXin Li 31*67e74705SXin Li 32*67e74705SXin Li @try { // expected-note 2 {{jump bypasses initialization of @try block}} 33*67e74705SXin Li L7: ; 34*67e74705SXin Li } @catch (C *c) { 35*67e74705SXin Li goto L7; // expected-error{{cannot jump}} 36*67e74705SXin Li } @finally { 37*67e74705SXin Li goto L7; // expected-error{{cannot jump}} 38*67e74705SXin Li } 39*67e74705SXin Li 40*67e74705SXin Li goto L8; // expected-error{{cannot jump}} 41*67e74705SXin Li @try { 42*67e74705SXin Li } @catch (A *c) { 43*67e74705SXin Li } @catch (B *c) { 44*67e74705SXin Li } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}} 45*67e74705SXin Li L8: ; 46*67e74705SXin Li } 47*67e74705SXin Li 48*67e74705SXin Li // rdar://6810106 49*67e74705SXin Li id X; 50*67e74705SXin Li goto L9; // expected-error{{cannot jump}} 51*67e74705SXin Li goto L10; // ok 52*67e74705SXin Li @synchronized // expected-note {{jump bypasses initialization of @synchronized block}} 53*67e74705SXin Li ( ({ L10: ; X; })) { 54*67e74705SXin Li L9: 55*67e74705SXin Li ; 56*67e74705SXin Li } 57*67e74705SXin Li} 58*67e74705SXin Li 59*67e74705SXin Livoid test2(int a) { 60*67e74705SXin Li if (a) goto L0; 61*67e74705SXin Li @try {} @finally {} 62*67e74705SXin Li L0: 63*67e74705SXin Li return; 64*67e74705SXin Li} 65*67e74705SXin Li 66*67e74705SXin Li// rdar://6803963 67*67e74705SXin Livoid test3() { 68*67e74705SXin Li @try { 69*67e74705SXin Li goto blargh; 70*67e74705SXin Li blargh: ; 71*67e74705SXin Li } @catch (...) {} 72*67e74705SXin Li} 73*67e74705SXin Li 74*67e74705SXin Li@interface Greeter 75*67e74705SXin Li+ (void) hello; 76*67e74705SXin Li@end 77*67e74705SXin Li 78*67e74705SXin Li@implementation Greeter 79*67e74705SXin Li+ (void) hello { 80*67e74705SXin Li 81*67e74705SXin Li @try { 82*67e74705SXin Li goto blargh; // expected-error {{cannot jump}} 83*67e74705SXin Li } @catch (...) { // expected-note {{jump bypasses initialization of @catch block}} 84*67e74705SXin Li blargh: ; 85*67e74705SXin Li } 86*67e74705SXin Li} 87*67e74705SXin Li 88*67e74705SXin Li+ (void)meth2 { 89*67e74705SXin Li int n; void *P; 90*67e74705SXin Li goto L0; // expected-error {{cannot jump}} 91*67e74705SXin Li typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}} 92*67e74705SXin Li L0: 93*67e74705SXin Li 94*67e74705SXin Li goto L1; // expected-error {{cannot jump}} 95*67e74705SXin Li A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}} 96*67e74705SXin Li L1: 97*67e74705SXin Li goto L2; // expected-error {{cannot jump}} 98*67e74705SXin Li A d[n]; // expected-note {{jump bypasses initialization of variable length array}} 99*67e74705SXin Li L2: 100*67e74705SXin Li return; 101*67e74705SXin Li} 102*67e74705SXin Li 103*67e74705SXin Li@end 104