]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wall -fblocks %s |
2 | ||
3 | // PR9463 | |
4 | double *end; | |
5 | void 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; | |
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 | ||
42 | void g() { | |
43 | end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}} | |
44 | } | |
45 | ||
46 | void h(int end) { | |
47 | { | |
48 | goto end; // expected-error{{use of undeclared label 'end'}} | |
49 | } | |
50 | } | |
51 | ||
52 | void 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 | ||
69 | void rdar9135994() | |
70 | { | |
71 | X: | |
72 | goto X; | |
73 | } | |
74 | ||
75 | namespace PR9495 { | |
76 | struct NonPOD { NonPOD(); ~NonPOD(); }; | |
77 | ||
78 | void f(bool b) { | |
79 | NonPOD np; | |
80 | if (b) { | |
81 | goto undeclared; // expected-error{{use of undeclared label 'undeclared'}} | |
82 | } | |
83 | } | |
84 | ||
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 | ||
99 | void f() { | |
100 | { | |
101 | goto exit; | |
102 | } | |
103 | exit: | |
104 | return; | |
105 | } | |
106 | ||
107 | namespace PR10620 { | |
108 | struct S { | |
109 | ~S() {} | |
110 | }; | |
111 | void g(const S& s) { | |
112 | goto done; // expected-error {{goto into protected scope}} | |
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(); }; | |
121 | void test(A a) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location | |
122 | goto lbl; // expected-error {{goto into protected scope}} | |
123 | (void) ^{ (void) a; }; | |
124 | lbl: | |
125 | return; | |
126 | } | |
127 | } |