Steve Naroff | 7e3ec6d | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | @class A, B, C; |
| 4 | |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 5 | void 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 Lattner | 0ec3c6a | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 9 | @try { // expected-note {{jump bypasses initialization of @try block}} |
Steve Naroff | 7e3ec6d | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 10 | L: ; |
Chris Lattner | 0ec3c6a | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 11 | } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}} |
Steve Naroff | 7e3ec6d | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 12 | L2: ; |
| 13 | } @catch (B *x) { |
| 14 | } @catch (C *c) { |
Chris Lattner | 0ec3c6a | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 15 | } @finally {// expected-note {{jump bypasses initialization of @finally block}} |
Steve Naroff | 7e3ec6d | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 16 | L3: ; |
| 17 | } |
Chris Lattner | 0ec3c6a | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 18 | |
| 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 Lattner | affa4e7 | 2009-04-18 22:35:34 +0000 | [diff] [blame^] | 42 | } @catch (A *c) { |
| 43 | } @catch (B *c) { |
Chris Lattner | 0ec3c6a | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 44 | } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}} |
| 45 | L8: ; |
| 46 | } |
| 47 | |
| 48 | |
Steve Naroff | 7e3ec6d | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 49 | } |
Steve Naroff | 7451170 | 2009-04-15 14:38:36 +0000 | [diff] [blame] | 50 | |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 51 | void test2(int a) { |
Steve Naroff | 7451170 | 2009-04-15 14:38:36 +0000 | [diff] [blame] | 52 | if (a) goto L0; |
| 53 | @try {} @finally {} |
| 54 | L0: |
| 55 | return; |
| 56 | } |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 57 | |
| 58 | // rdar://6803963 |
| 59 | void test3() { |
| 60 | @try { |
| 61 | goto blargh; |
| 62 | blargh: ; |
| 63 | } @catch (...) {} |
| 64 | } |