]> git.proxmox.com Git - rustc.git/blame - src/test/ui/asm/x86_64/may_unwind.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / asm / x86_64 / may_unwind.rs
CommitLineData
a2a8927a
XL
1// only-x86_64
2// run-pass
3// needs-asm-support
f2b60f7d 4// needs-unwind
a2a8927a 5
2b03887a 6#![feature(asm_unwind)]
a2a8927a
XL
7
8use std::arch::asm;
9use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
10
11struct Foo<'a>(&'a mut bool);
12
13impl Drop for Foo<'_> {
14 fn drop(&mut self) {
15 *self.0 = false;
16 }
17}
18
19extern "C" fn panicky() {
20 resume_unwind(Box::new(()));
21}
22
23fn 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}