1 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fcxx-exceptions %s -Wno-unreachable-code
2 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fcxx-exceptions -std=gnu++11 %s -Wno-unreachable-code
23 goto foo; // expected-error {{goto into protected scope}}
24 C c; // expected-note {{jump bypasses variable initialization}}
34 static void *ips[] = { &&lbl1, &&lbl2 };
49 static void *ips[] = { &&lbl1, &&lbl2 };
66 static void *ips[] = { &&lbl1, &&lbl2 };
70 goto *ip; // expected-error {{indirect goto might cross protected scopes}}
71 C c1; // expected-note {{jump bypasses variable initialization}}
72 lbl1: // expected-note {{possible target of indirect goto}}
84 static void *ips[] = { &&lbl1, &&lbl2 };
88 lbl1: // expected-note {{possible target of indirect goto}}
92 D d; // expected-note {{jump exits scope of variable with non-trivial destructor}}
94 goto *ip; // expected-error {{indirect goto might cross protected scopes}}
103 unsigned f(unsigned s0, unsigned s1, void **ip) {
104 static void *ips[] = { &&lbl1, &&lbl2, &&lbl3, &&lbl4 };
125 // C++0x says it's okay to skip non-trivial initializers on static
126 // locals, and we implement that in '03 as well.
143 int x = 56; // expected-note {{jump bypasses variable initialization}}
144 case 1: // expected-error {{switch case is in protected scope}}
150 goto l2; // expected-error {{goto into protected scope}}
151 l1: int x = 5; // expected-note {{jump bypasses variable initialization}}
164 unsigned test2(unsigned x, unsigned y) {
168 if (y > 42) return x + y;
175 // http://llvm.org/PR10462
184 switch (K) { // expected-warning {{enumeration value 'something_invalid' not handled in switch}}
185 case something_valid:
186 case what_am_i_thinking: // expected-error {{use of undeclared identifier}}
198 static void *ps[] = { &&a0 };
199 goto *&&a0; // expected-error {{goto into protected scope}}
200 int a = 3; // expected-note {{jump bypasses variable initialization}}
213 static void *ips[] = { &&l0 };
214 l0: // expected-note {{possible target of indirect goto}}
215 C c0 = 42; // expected-note {{jump exits scope of variable with non-trivial destructor}}
216 goto *ip; // expected-error {{indirect goto might cross protected scopes}}
226 static void *ips[] = { &&l0 };
228 l0: // expected-note {{possible target of indirect goto}}
229 const C &c1 = 42; // expected-note {{jump exits scope of variable with non-trivial destructor}}
231 goto *ip; // expected-error {{indirect goto might cross protected scopes}}
242 static void *ips[] = { &&l0 };
243 l0: // expected-note {{possible target of indirect goto}}
244 const int &c1 = C(1).i; // expected-note {{jump exits scope of variable with non-trivial destructor}}
245 goto *ip; // expected-error {{indirect goto might cross protected scopes}}
253 operator int&() const;
256 static void *ips[] = { &&l0 };
258 // no warning since the C temporary is destructed before the goto.
259 const int &c1 = C(1);
267 goto x; // expected-error {{goto into protected scope}}
268 } catch(...) { // expected-note {{jump bypasses initialization of catch block}}
271 void f2() try { // expected-note {{jump bypasses initialization of try block}}
274 goto x; // expected-error {{goto into protected scope}}