Clang Project

clang_source_code/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4
5// PR10034
6struct X {};
7
8void exx(X) {}
9
10int test_ptr10034(int argc, char **argv)
11{
12 if (argc > 3)
13   goto end;
14
15 X x;
16 X xs[16];
17 exx(x);
18
19 end:
20   if (argc > 1) {
21   for (int i = 0; i < argc; ++i)
22   {
23
24   }
25   }
26   return 0;
27}
28
29struct Y {
30  ~Y();
31};
32
33void test_Y() {
34  goto end; // expected-error{{cannot jump from this goto statement to its label}}
35  Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
36 end:
37  return;
38}
39
40struct Z {
41  Z operator=(const Z&);
42};
43
44void test_Z() {
45  goto end;
46#if __cplusplus <= 199711L
47  // expected-error@-2 {{cannot jump from this goto statement to its label}}
48#endif
49
50  Z z;
51#if __cplusplus <= 199711L
52  // expected-note@-2 {{jump bypasses initialization of non-POD variable}}
53#endif
54
55 end:
56  return;
57}
58