2019-12-26 09:37:48 -06:00
|
|
|
// compile-flags: -O
|
|
|
|
|
2022-03-16 07:12:30 -05:00
|
|
|
// On x86 the closure is inlined in foo() producing something like
|
2020-06-04 06:13:36 -05:00
|
|
|
// define i32 @foo() [...] {
|
|
|
|
// tail call void @bar() [...]
|
|
|
|
// ret i32 0
|
|
|
|
// }
|
|
|
|
// On riscv the closure is another function, placed before fn foo so CHECK can't
|
|
|
|
// find it
|
|
|
|
// ignore-riscv64 FIXME
|
2022-12-06 11:12:46 -06:00
|
|
|
// On s390x the closure is also in another function
|
|
|
|
// ignore-s390x FIXME
|
2023-04-14 04:42:08 -05:00
|
|
|
// On loongarch64 the closure is also in another function
|
|
|
|
// ignore-loongarch64 FIXME
|
2020-06-04 06:13:36 -05:00
|
|
|
|
2019-12-26 09:37:48 -06:00
|
|
|
#![crate_type = "lib"]
|
2021-06-08 13:23:58 -05:00
|
|
|
#![feature(c_unwind)]
|
2019-12-26 09:37:48 -06:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
fn bar();
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @foo
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe fn foo() -> i32 {
|
|
|
|
// CHECK: call void @bar
|
|
|
|
// CHECK: ret i32 0
|
|
|
|
std::panic::catch_unwind(|| {
|
|
|
|
bar();
|
|
|
|
0
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
}
|