goto.cpp revision c9977d09a2de7f7d2245973413d4caf86c736640
1// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s 2 3// PR9463 4double *end; 5void f() { 6 { 7 int end = 0; 8 goto end; 9 end = 1; 10 } 11 12 end: 13 return; 14} 15 16void g() { 17 end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}} 18} 19 20void h(int end) { 21 { 22 goto end; // expected-error{{use of undeclared label 'end'}} 23 } 24} 25 26void h2(int end) { 27 { 28 __label__ end; 29 goto end; 30 31 end: 32 ::end = 0; 33 } 34 end: 35 end = 1; 36} 37 38class X { 39public: 40 X(); 41}; 42 43void rdar9135994() 44{ 45X: 46 goto X; 47} 48 49namespace PR9495 { 50 struct NonPOD { NonPOD(); ~NonPOD(); }; 51 52 void f(bool b) { 53 NonPOD np; 54 if (b) { 55 goto undeclared; // expected-error{{use of undeclared label 'undeclared'}} 56 } 57 } 58 59 void g() { 60 (void)^(bool b){ 61 NonPOD np; 62 if (b) { 63 goto undeclared; // expected-error{{use of undeclared label 'undeclared'}} 64 } 65 }; 66 } 67} 68 69 70