| Jennifer Yu | 954ec09 | 2019-05-30 01:05:46 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only |
| 2 | |
| 3 | struct NonTrivial { |
| 4 | ~NonTrivial(); |
| 5 | int f(int); |
| 6 | private: |
| 7 | int k; |
| 8 | }; |
| 9 | void 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 | |
| 15 | DirectJump: |
| 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}} |
| 21 | Later: |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | struct S { ~S(); }; |
| 26 | void foo(int a) { |
| 27 | if (a) { |
| 28 | FOO: |
| 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}} |
| 43 | BAR: |
| 44 | return; |
| 45 | } |