blob: d8d5ec51f6e40f518cf69b1625f67c6b9d74d8d1 [file] [log] [blame]
Douglas Gregor1d2de762011-03-24 14:35:16 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wall -fblocks %s
Douglas Gregorc9977d02011-03-16 17:05:57 +00002
Douglas Gregor7cbc5582011-03-14 21:19:51 +00003// PR9463
4double *end;
Douglas Gregorbec73432011-03-23 21:19:43 +00005void f(bool b1, bool b2) {
Douglas Gregor7cbc5582011-03-14 21:19:51 +00006 {
Douglas Gregorbec73432011-03-23 21:19:43 +00007 do {
8 int end = 0;
9 if (b2) {
10 do {
11 goto end;
12 } while (b2);
13 }
14 end = 1;
15 } while (b1);
Douglas Gregor7cbc5582011-03-14 21:19:51 +000016 }
17
18 end:
19 return;
20}
21
Douglas Gregorfa7b8ce2011-03-24 10:35:39 +000022namespace 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
Douglas Gregor7cbc5582011-03-14 21:19:51 +000042void g() {
43 end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}}
44}
Douglas Gregor250e7a72011-03-16 16:39:03 +000045
46void h(int end) {
47 {
48 goto end; // expected-error{{use of undeclared label 'end'}}
49 }
50}
51
52void h2(int end) {
53 {
54 __label__ end;
55 goto end;
56
57 end:
58 ::end = 0;
59 }
Douglas Gregor1d2de762011-03-24 14:35:16 +000060 end: // expected-warning{{unused label 'end'}}
Douglas Gregor250e7a72011-03-16 16:39:03 +000061 end = 1;
62}
63
64class X {
65public:
66 X();
67};
68
69void rdar9135994()
70{
71X:
72 goto X;
73}
Douglas Gregorc9977d02011-03-16 17:05:57 +000074
75namespace 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
Douglas Gregor1d2de762011-03-24 14:35:16 +000095extern "C" {
96 void exit(int);
97}
Douglas Gregorc9977d02011-03-16 17:05:57 +000098
Douglas Gregor1d2de762011-03-24 14:35:16 +000099void f() {
100 {
101 goto exit;
102 }
103 exit:
104 return;
105}