scope-check.c revision 5ce71c99cf00f24f876548d7f0dd0eefac47b168
1// RUN: clang-cc -fsyntax-only -verify %s 2 3int test1(int x) { 4 goto L; // expected-error{{illegal goto into protected scope}} 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}} 7 L: 8 return sizeof a; 9} 10 11int test2(int x) { 12 goto L; // expected-error{{illegal goto into protected scope}} 13 typedef int a[x]; // expected-note {{jump bypasses initialization of VLA typedef}} 14 L: 15 return sizeof(a); 16} 17 18void test3clean(int*); 19 20int test3() { 21 goto L; // expected-error{{illegal goto into protected scope}} 22int a __attribute((cleanup(test3clean))); // expected-note {{jump bypasses initialization of declaration with __attribute__((cleanup))}} 23L: 24 return a; 25} 26 27int test4(int x) { 28 goto L; // expected-error{{illegal goto into protected scope}} 29int a[x]; // expected-note {{jump bypasses initialization of variable length array}} 30 test4(x); 31L: 32 return sizeof a; 33} 34 35int test5(int x) { 36 int a[x]; 37 test5(x); 38 goto L; // Ok. 39L: 40 goto L; // Ok. 41 return sizeof a; 42} 43 44int test6() { 45 // just plain invalid. 46 goto x; // expected-error {{use of undeclared label 'x'}} 47} 48 49 50// FIXME: Switch cases etc. 51