Anders Carlsson | e9b801f | 2011-02-22 01:52:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s |
Steve Naroff | 1fc5194 | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 2 | |
| 3 | @class A, B, C; |
| 4 | |
Chris Lattner | a5251fc | 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 | 07e775d | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 9 | @try { // expected-note {{jump bypasses initialization of @try block}} |
Steve Naroff | 1fc5194 | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 10 | L: ; |
Chris Lattner | 07e775d | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 11 | } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}} |
Steve Naroff | 1fc5194 | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 12 | L2: ; |
| 13 | } @catch (B *x) { |
| 14 | } @catch (C *c) { |
Chris Lattner | 07e775d | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 15 | } @finally {// expected-note {{jump bypasses initialization of @finally block}} |
Steve Naroff | 1fc5194 | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 16 | L3: ; |
| 17 | } |
Chris Lattner | 07e775d | 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 | dabbad0 | 2009-04-18 22:35:34 +0000 | [diff] [blame] | 42 | } @catch (A *c) { |
| 43 | } @catch (B *c) { |
Chris Lattner | 07e775d | 2009-04-18 21:28:52 +0000 | [diff] [blame] | 44 | } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}} |
| 45 | L8: ; |
| 46 | } |
Chris Lattner | 46c3c4b | 2009-04-21 06:01:00 +0000 | [diff] [blame] | 47 | |
| 48 | // rdar://6810106 |
| 49 | id X; |
| 50 | goto L9; // expected-error{{illegal goto into protected scope}} |
| 51 | goto L10; // ok |
| 52 | @synchronized // expected-note {{jump bypasses initialization of @synchronized block}} |
| 53 | ( ({ L10: ; X; })) { |
| 54 | L9: |
| 55 | ; |
| 56 | } |
Steve Naroff | 1fc5194 | 2009-04-14 20:53:38 +0000 | [diff] [blame] | 57 | } |
Steve Naroff | b25ddfb | 2009-04-15 14:38:36 +0000 | [diff] [blame] | 58 | |
Chris Lattner | a5251fc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 59 | void test2(int a) { |
Steve Naroff | b25ddfb | 2009-04-15 14:38:36 +0000 | [diff] [blame] | 60 | if (a) goto L0; |
| 61 | @try {} @finally {} |
| 62 | L0: |
| 63 | return; |
| 64 | } |
Chris Lattner | a5251fc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 65 | |
| 66 | // rdar://6803963 |
| 67 | void test3() { |
| 68 | @try { |
| 69 | goto blargh; |
| 70 | blargh: ; |
| 71 | } @catch (...) {} |
| 72 | } |
Chris Lattner | 5223af8 | 2009-04-18 22:37:38 +0000 | [diff] [blame] | 73 | |
| 74 | @interface Greeter |
| 75 | + (void) hello; |
| 76 | @end |
| 77 | |
| 78 | @implementation Greeter |
| 79 | + (void) hello { |
| 80 | |
| 81 | @try { |
| 82 | goto blargh; // expected-error {{illegal goto into protected scope}} |
| 83 | } @catch (...) { // expected-note {{jump bypasses initialization of @catch block}} |
| 84 | blargh: ; |
| 85 | } |
| 86 | } |
Chris Lattner | 4f9c06a | 2009-04-19 05:20:37 +0000 | [diff] [blame] | 87 | |
| 88 | + (void)meth2 { |
| 89 | int n; void *P; |
| 90 | goto L0; // expected-error {{illegal goto into protected scope}} |
| 91 | typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}} |
| 92 | L0: |
| 93 | |
| 94 | goto L1; // expected-error {{illegal goto into protected scope}} |
| 95 | A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}} |
| 96 | L1: |
| 97 | goto L2; // expected-error {{illegal goto into protected scope}} |
| 98 | A d[n]; // expected-note {{jump bypasses initialization of variable length array}} |
| 99 | L2: |
| 100 | return; |
| 101 | } |
| 102 | |
Chris Lattner | 5223af8 | 2009-04-18 22:37:38 +0000 | [diff] [blame] | 103 | @end |