goto.cpp revision fa7b8ced6f3318879b39f44b5ace8346e979826e
1// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
2
3// PR9463
4double *end;
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
22namespace 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
42void g() {
43  end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}}
44}
45
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  }
60 end:
61  end = 1;
62}
63
64class X {
65public:
66  X();
67};
68
69void rdar9135994()
70{
71X:
72    goto X;
73}
74
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
95
96