]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/x86_64/may_unwind.rs
Auto merge of #98471 - wesleywiser:update_measureme, r=Mark-Simulacrum
[rust.git] / src / test / ui / asm / x86_64 / may_unwind.rs
1 // min-llvm-version: 13.0.0
2 // only-x86_64
3 // run-pass
4 // needs-asm-support
5
6 #![feature(asm_sym, asm_unwind)]
7
8 use std::arch::asm;
9 use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
10
11 struct Foo<'a>(&'a mut bool);
12
13 impl Drop for Foo<'_> {
14     fn drop(&mut self) {
15         *self.0 = false;
16     }
17 }
18
19 extern "C" fn panicky() {
20     resume_unwind(Box::new(()));
21 }
22
23 fn main() {
24     let flag = &mut true;
25     catch_unwind(AssertUnwindSafe(|| {
26         let _foo = Foo(flag);
27         unsafe {
28             asm!(
29                 "call {}",
30                 sym panicky,
31                 clobber_abi("C"),
32                 options(may_unwind)
33             );
34         }
35     }))
36     .expect_err("expected a panic");
37     assert_eq!(*flag, false);
38 }