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 | } |
Steve Naroff | 7e3ec6d | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 47 | } |
Steve Naroff | 7451170 | 2009-04-15 14:38:36 +0000 | [diff] [blame] | 48 | |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 49 | void test2(int a) { |
Steve Naroff | 7451170 | 2009-04-15 14:38:36 +0000 | [diff] [blame] | 50 | if (a) goto L0; |
| 51 | @try {} @finally {} |
| 52 | L0: |
| 53 | return; |
| 54 | } |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 55 | |
| 56 | // rdar://6803963 |
| 57 | void test3() { |
| 58 | @try { |
| 59 | goto blargh; |
| 60 | blargh: ; |
| 61 | } @catch (...) {} |
| 62 | } |
Chris Lattner | 64af85e | 2009-04-18 22:37:38 +0000 | [diff] [blame] | 63 | |
| 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 Lattner | b3ce45b | 2009-04-19 05:20:37 +0000 | [diff] [blame^] | 77 | |
| 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 Lattner | 64af85e | 2009-04-18 22:37:38 +0000 | [diff] [blame] | 93 | @end |