blob: f61a8096b83ecb72b73c7cf3864ab09ecf5bada0 [file] [log] [blame]
Jennifer Yu954ec092019-05-30 01:05:46 +00001// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
2
3struct NonTrivial {
4 ~NonTrivial();
5 int f(int);
6private:
7 int k;
8};
9void JumpDiagnostics(int n) {
10// expected-error@+1 {{cannot jump from this goto statement to its label}}
11 goto DirectJump;
12// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
13 NonTrivial tnp1;
14
15DirectJump:
16// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
17 asm goto("jmp %l0;" ::::Later);
18// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
19 NonTrivial tnp2;
20// expected-note@+1 {{possible target of asm goto statement}}
21Later:
22 return;
23}
24
25struct S { ~S(); };
26void foo(int a) {
27 if (a) {
28FOO:
29// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
30// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
31 S s;
32 void *p = &&BAR;
33// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
34 asm goto("jmp %l0;" ::::BAR);
35// expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible targets}}
36 goto *p;
37 p = &&FOO;
38 goto *p;
39 return;
40 }
41// expected-note@+2 {{possible target of asm goto statement}}
42// expected-note@+1 {{possible target of indirect goto statement}}
43BAR:
44 return;
45}