blob: 7da4e429a68abab3a12a4b1d938df37b02d3640a [file] [log] [blame]
Steve Naroff7e3ec6d2009-04-14 20:53:38 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3@class A, B, C;
4
Chris Lattnere44e5cc2009-04-18 09:36:27 +00005void test1() {
6 goto L; // expected-error{{illegal goto into protected scope}}
7 goto L2; // expected-error{{illegal goto into protected scope}}
8 goto L3; // expected-error{{illegal goto into protected scope}}
Chris Lattner0ec3c6a2009-04-18 21:28:52 +00009 @try { // expected-note {{jump bypasses initialization of @try block}}
Steve Naroff7e3ec6d2009-04-14 20:53:38 +000010L: ;
Chris Lattner0ec3c6a2009-04-18 21:28:52 +000011 } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
Steve Naroff7e3ec6d2009-04-14 20:53:38 +000012L2: ;
13 } @catch (B *x) {
14 } @catch (C *c) {
Chris Lattner0ec3c6a2009-04-18 21:28:52 +000015 } @finally {// expected-note {{jump bypasses initialization of @finally block}}
Steve Naroff7e3ec6d2009-04-14 20:53:38 +000016L3: ;
17 }
Chris Lattner0ec3c6a2009-04-18 21:28:52 +000018
19 @try {
20 goto L4; // expected-error{{illegal goto into protected scope}}
21 goto L5; // expected-error{{illegal goto into protected scope}}
22 } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
23 L5: ;
24 goto L6; // expected-error{{illegal goto into protected scope}}
25 } @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
26 L6: ;
27 } @finally { // expected-note {{jump bypasses initialization of @finally block}}
28 L4: ;
29 }
30
31
32 @try { // expected-note 2 {{jump bypasses initialization of @try block}}
33 L7: ;
34 } @catch (C *c) {
35 goto L7; // expected-error{{illegal goto into protected scope}}
36 } @finally {
37 goto L7; // expected-error{{illegal goto into protected scope}}
38 }
39
40 goto L8; // expected-error{{illegal goto into protected scope}}
41 @try {
Chris Lattneraffa4e72009-04-18 22:35:34 +000042 } @catch (A *c) {
43 } @catch (B *c) {
Chris Lattner0ec3c6a2009-04-18 21:28:52 +000044 } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
45 L8: ;
46 }
Steve Naroff7e3ec6d2009-04-14 20:53:38 +000047}
Steve Naroff74511702009-04-15 14:38:36 +000048
Chris Lattnere44e5cc2009-04-18 09:36:27 +000049void test2(int a) {
Steve Naroff74511702009-04-15 14:38:36 +000050 if (a) goto L0;
51 @try {} @finally {}
52 L0:
53 return;
54}
Chris Lattnere44e5cc2009-04-18 09:36:27 +000055
56// rdar://6803963
57void test3() {
58 @try {
59 goto blargh;
60 blargh: ;
61 } @catch (...) {}
62}
Chris Lattner64af85e2009-04-18 22:37:38 +000063
64@interface Greeter
65+ (void) hello;
66@end
67
68@implementation Greeter
69+ (void) hello {
70
71 @try {
72 goto blargh; // expected-error {{illegal goto into protected scope}}
73 } @catch (...) { // expected-note {{jump bypasses initialization of @catch block}}
74 blargh: ;
75 }
76}
Chris Lattnerb3ce45b2009-04-19 05:20:37 +000077
78+ (void)meth2 {
79 int n; void *P;
80 goto L0; // expected-error {{illegal goto into protected scope}}
81 typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}}
82 L0:
83
84 goto L1; // expected-error {{illegal goto into protected scope}}
85 A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
86 L1:
87 goto L2; // expected-error {{illegal goto into protected scope}}
88 A d[n]; // expected-note {{jump bypasses initialization of variable length array}}
89 L2:
90 return;
91}
92
Chris Lattner64af85e2009-04-18 22:37:38 +000093@end