]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/catch-unwind.rs
Rollup merge of #102954 - GuillaumeGomez:cfg-hide-attr-checks, r=Manishearth
[rust.git] / src / test / 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
12 #![crate_type = "lib"]
13 #![feature(c_unwind)]
14
15 extern "C" {
16     fn bar();
17 }
18
19 // CHECK-LABEL: @foo
20 #[no_mangle]
21 pub unsafe fn foo() -> i32 {
22     // CHECK: call void @bar
23     // CHECK: ret i32 0
24     std::panic::catch_unwind(|| {
25         bar();
26         0
27     })
28     .unwrap()
29 }