1 // RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
2 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -verify -fsyntax-only
3
4 struct S {
5 ~S();
6 int f(int);
7 private:
8 int k;
9 };
test1(int n)10 void test1(int n) {
11 // expected-error@+1 {{cannot jump from this goto statement to its label}}
12 goto DirectJump;
13 // expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
14 S s1;
15
16 DirectJump:
17 // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
18 asm goto("jmp %l0;" ::::Later);
19 // expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
20 S s2;
21 // expected-note@+1 {{possible target of asm goto statement}}
22 Later:
23 return;
24 }
25
26 struct T { ~T(); };
test2(int a)27 void test2(int a) {
28 if (a) {
29 FOO:
30 // expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
31 // expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
32 T t;
33 void *p = &&BAR;
34 // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
35 asm goto("jmp %l0;" ::::BAR);
36 // expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible targets}}
37 goto *p;
38 p = &&FOO;
39 goto *p;
40 return;
41 }
42 // expected-note@+2 {{possible target of asm goto statement}}
43 // expected-note@+1 {{possible target of indirect goto statement}}
44 BAR:
45 return;
46 }
47
test3(int n)48 int test3(int n)
49 {
50 // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
51 // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
52 asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
53 // expected-note@+2 {{jump bypasses initialization of variable length array}}
54 // expected-note@+1 {{possible target of asm goto statement}}
55 return ({int a[n];label_true: 2;});
56 // expected-note@+1 {{jump bypasses initialization of variable length array}}
57 int b[n];
58 // expected-note@+1 {{possible target of asm goto statement}}
59 loop:
60 return 0;
61 }
62