Daniel Dunbar | ffd408a | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Eli Friedman | 9c0e6f9 | 2009-02-28 05:41:13 +0000 | [diff] [blame] | 2 | |
| 3 | int test1(int x) { |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 4 | goto L; // expected-error{{illegal goto into protected scope}} |
Chris Lattner | 930cc9a | 2009-04-18 18:42:55 +0000 | [diff] [blame] | 5 | int a[x]; // expected-note {{jump bypasses initialization of variable length array}} |
| 6 | int b[x]; // expected-note {{jump bypasses initialization of variable length array}} |
Eli Friedman | 9c0e6f9 | 2009-02-28 05:41:13 +0000 | [diff] [blame] | 7 | L: |
| 8 | return sizeof a; |
| 9 | } |
Eli Friedman | ea91729 | 2009-02-28 06:22:14 +0000 | [diff] [blame] | 10 | |
| 11 | int test2(int x) { |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 12 | goto L; // expected-error{{illegal goto into protected scope}} |
Chris Lattner | 930cc9a | 2009-04-18 18:42:55 +0000 | [diff] [blame] | 13 | typedef int a[x]; // expected-note {{jump bypasses initialization of VLA typedef}} |
Eli Friedman | ea91729 | 2009-02-28 06:22:14 +0000 | [diff] [blame] | 14 | L: |
| 15 | return sizeof(a); |
| 16 | } |
| 17 | |
| 18 | void test3clean(int*); |
| 19 | |
| 20 | int test3() { |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 21 | goto L; // expected-error{{illegal goto into protected scope}} |
Chris Lattner | 930cc9a | 2009-04-18 18:42:55 +0000 | [diff] [blame] | 22 | int a __attribute((cleanup(test3clean))); // expected-note {{jump bypasses initialization of declaration with __attribute__((cleanup))}} |
Chris Lattner | 01c5fc0 | 2009-04-18 07:54:11 +0000 | [diff] [blame] | 23 | L: |
Eli Friedman | ea91729 | 2009-02-28 06:22:14 +0000 | [diff] [blame] | 24 | return a; |
| 25 | } |
Steve Naroff | d91d1f8 | 2009-04-15 16:58:41 +0000 | [diff] [blame] | 26 | |
| 27 | int test4(int x) { |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 28 | goto L; // expected-error{{illegal goto into protected scope}} |
Chris Lattner | 930cc9a | 2009-04-18 18:42:55 +0000 | [diff] [blame] | 29 | int a[x]; // expected-note {{jump bypasses initialization of variable length array}} |
Chris Lattner | 01c5fc0 | 2009-04-18 07:54:11 +0000 | [diff] [blame] | 30 | test4(x); |
| 31 | L: |
| 32 | return sizeof a; |
Steve Naroff | d91d1f8 | 2009-04-15 16:58:41 +0000 | [diff] [blame] | 33 | } |
Chris Lattner | 01c5fc0 | 2009-04-18 07:54:11 +0000 | [diff] [blame] | 34 | |
| 35 | int test5(int x) { |
| 36 | int a[x]; |
| 37 | test5(x); |
| 38 | goto L; // Ok. |
| 39 | L: |
| 40 | goto L; // Ok. |
| 41 | return sizeof a; |
| 42 | } |
| 43 | |
Chris Lattner | e44e5cc | 2009-04-18 09:36:27 +0000 | [diff] [blame] | 44 | int test6() { |
| 45 | // just plain invalid. |
| 46 | goto x; // expected-error {{use of undeclared label 'x'}} |
| 47 | } |
| 48 | |
Chris Lattner | 69a480e | 2009-04-18 19:42:37 +0000 | [diff] [blame^] | 49 | void test7(int x) { |
| 50 | foo: |
| 51 | switch (x) { // expected-error {{illegal switch into protected scope}} |
| 52 | case 1: ; |
| 53 | int a[x]; // expected-note {{jump bypasses initialization of variable length array}} |
| 54 | case 2: |
| 55 | a[1] = 2; |
| 56 | break; |
| 57 | } |
| 58 | } |
| 59 | |
Chris Lattner | 01c5fc0 | 2009-04-18 07:54:11 +0000 | [diff] [blame] | 60 | |
| 61 | // FIXME: Switch cases etc. |