Sebastian Redl | 4de47b4 | 2009-04-27 20:27:31 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | struct A; // expected-note 4 {{forward declaration of 'struct A'}} |
| 4 | |
| 5 | void trys() { |
| 6 | try { |
| 7 | } catch(int i) { // expected-note {{previous definition}} |
| 8 | int j = i; |
| 9 | int i; // expected-error {{redefinition of 'i'}} |
| 10 | } catch(float i) { |
| 11 | } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}} |
| 12 | } catch(A a) { // expected-error {{cannot catch incomplete type 'struct A'}} |
| 13 | } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'struct A'}} |
| 14 | } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'struct A'}} |
| 15 | } catch(...) { |
| 16 | int j = i; // expected-error {{use of undeclared identifier 'i'}} |
| 17 | } |
| 18 | |
| 19 | try { |
| 20 | } catch(...) { // expected-error {{catch-all handler must come last}} |
| 21 | } catch(int) { |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | void throws() { |
| 26 | throw; |
| 27 | throw 0; |
| 28 | throw throw; // expected-error {{cannot throw object of incomplete type 'void'}} |
| 29 | throw (A*)0; // expected-error {{cannot throw pointer to object of incomplete type 'struct A'}} |
| 30 | } |
| 31 | |
| 32 | void jumps() { |
| 33 | l1: |
| 34 | goto l5; |
| 35 | goto l4; // expected-error {{illegal goto into protected scope}} |
| 36 | goto l3; // expected-error {{illegal goto into protected scope}} |
| 37 | goto l2; // expected-error {{illegal goto into protected scope}} |
| 38 | goto l1; |
| 39 | try { // expected-note 4 {{jump bypasses initialization of try block}} |
| 40 | l2: |
| 41 | goto l5; |
| 42 | goto l4; // expected-error {{illegal goto into protected scope}} |
| 43 | goto l3; // expected-error {{illegal goto into protected scope}} |
| 44 | goto l2; |
| 45 | goto l1; |
| 46 | } catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}} |
| 47 | l3: |
| 48 | goto l5; |
| 49 | goto l4; // expected-error {{illegal goto into protected scope}} |
| 50 | goto l3; |
| 51 | goto l2; // expected-error {{illegal goto into protected scope}} |
| 52 | goto l1; |
| 53 | } catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}} |
| 54 | l4: |
| 55 | goto l5; |
| 56 | goto l4; |
| 57 | goto l3; // expected-error {{illegal goto into protected scope}} |
| 58 | goto l2; // expected-error {{illegal goto into protected scope}} |
| 59 | goto l1; |
| 60 | } |
| 61 | l5: |
| 62 | goto l5; |
| 63 | goto l4; // expected-error {{illegal goto into protected scope}} |
| 64 | goto l3; // expected-error {{illegal goto into protected scope}} |
| 65 | goto l2; // expected-error {{illegal goto into protected scope}} |
| 66 | goto l1; |
| 67 | } |