]> git.lizzy.rs Git - rust.git/blob - tests/codegen/catch-unwind.rs
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
[rust.git] / tests / codegen / catch-unwind.rs
1 // compile-flags: -O
2
3 // On x86 the closure is inlined in foo() producing something like
4 // define i32 @foo() [...] {
5 // tail call void @bar() [...]
6 // ret i32 0
7 // }
8 // On riscv the closure is another function, placed before fn foo so CHECK can't
9 // find it
10 // ignore-riscv64 FIXME
11 // On s390x the closure is also in another function
12 // ignore-s390x FIXME
13
14 #![crate_type = "lib"]
15 #![feature(c_unwind)]
16
17 extern "C" {
18     fn bar();
19 }
20
21 // CHECK-LABEL: @foo
22 #[no_mangle]
23 pub unsafe fn foo() -> i32 {
24     // CHECK: call void @bar
25     // CHECK: ret i32 0
26     std::panic::catch_unwind(|| {
27         bar();
28         0
29     })
30     .unwrap()
31 }