]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/catch-unwind.rs
Merge commit '4236289b75ee55c78538c749512cdbeea5e1c332' into update-rustfmt
[rust.git] / src / test / codegen / catch-unwind.rs
1 // compile-flags: -O
2
3 // On x86 the closure is inlined in foo() producting 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
14 extern "C" {
15     fn bar();
16 }
17
18 // CHECK-LABEL: @foo
19 #[no_mangle]
20 pub unsafe fn foo() -> i32 {
21     // CHECK: call void @bar
22     // CHECK: ret i32 0
23     std::panic::catch_unwind(|| {
24         bar();
25         0
26     })
27     .unwrap()
28 }