1 // RUN: %clang_cc1 -fsyntax-only -verify -Wall -fblocks %s 2 3 // PR9463 4 double *end; f(bool b1,bool b2)5void f(bool b1, bool b2) { 6 { 7 do { 8 int end = 0; 9 if (b2) { 10 do { 11 goto end; 12 } while (b2); 13 } 14 end = 1; 15 } while (b1); 16 } 17 18 end: 19 return; 20 } 21 22 namespace N { 23 float* end; f(bool b1,bool b2)24 void f(bool b1, bool b2) { 25 { 26 do { 27 int end = 0; 28 if (b2) { 29 do { 30 goto end; 31 } while (b2); 32 } 33 end = 1; 34 } while (b1); 35 } 36 37 end: 38 return; 39 } 40 } 41 g()42void g() { 43 end = 1; // expected-error{{incompatible integer to pointer conversion assigning to 'double *' from 'int'}} 44 } 45 h(int end)46void h(int end) { 47 { 48 goto end; // expected-error{{use of undeclared label 'end'}} 49 } 50 } 51 h2(int end)52void h2(int end) { 53 { 54 __label__ end; 55 goto end; 56 57 end: 58 ::end = 0; 59 } 60 end: // expected-warning{{unused label 'end'}} 61 end = 1; 62 } 63 64 class X { 65 public: 66 X(); 67 }; 68 rdar9135994()69void rdar9135994() 70 { 71 X: 72 goto X; 73 } 74 75 namespace PR9495 { 76 struct NonPOD { NonPOD(); ~NonPOD(); }; 77 f(bool b)78 void f(bool b) { 79 NonPOD np; 80 if (b) { 81 goto undeclared; // expected-error{{use of undeclared label 'undeclared'}} 82 } 83 } 84 g()85 void g() { 86 (void)^(bool b){ 87 NonPOD np; 88 if (b) { 89 goto undeclared; // expected-error{{use of undeclared label 'undeclared'}} 90 } 91 }; 92 } 93 } 94 95 extern "C" { 96 void exit(int); 97 } 98 f()99void f() { 100 { 101 goto exit; 102 } 103 exit: 104 return; 105 } 106 107 namespace PR10620 { 108 struct S { ~SPR10620::S109 ~S() {} 110 }; g(const S & s)111 void g(const S& s) { 112 goto done; // expected-error {{cannot jump}} 113 const S s2(s); // expected-note {{jump bypasses variable initialization}} 114 done: 115 ; 116 } 117 } 118 119 namespace test12 { 120 struct A { A(); A(const A&); ~A(); }; test(A a)121 void test(A a) { // expected-note {{jump enters lifetime of block}} FIXME: weird location 122 goto lbl; // expected-error {{cannot jump}} 123 (void) ^{ (void) a; }; 124 lbl: 125 return; 126 } 127 } 128