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