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