blob: fb9bd4570dda3e79132cf40869b5dfa89f3947b9 [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 }
47
48
Steve Naroff7e3ec6d2009-04-14 20:53:38 +000049}
Steve Naroff74511702009-04-15 14:38:36 +000050
Chris Lattnere44e5cc2009-04-18 09:36:27 +000051void test2(int a) {
Steve Naroff74511702009-04-15 14:38:36 +000052 if (a) goto L0;
53 @try {} @finally {}
54 L0:
55 return;
56}
Chris Lattnere44e5cc2009-04-18 09:36:27 +000057
58// rdar://6803963
59void test3() {
60 @try {
61 goto blargh;
62 blargh: ;
63 } @catch (...) {}
64}