2019-12-26 15:37:48 +00:00
|
|
|
// compile-flags: -O
|
|
|
|
|
2022-03-16 12:12:30 +00:00
|
|
|
// On x86 the closure is inlined in foo() producing something like
|
2020-06-04 11:13:36 +00: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 17:12:46 +00:00
|
|
|
// On s390x the closure is also in another function
|
|
|
|
// ignore-s390x FIXME
|
2023-04-14 09:42:08 +00:00
|
|
|
// On loongarch64 the closure is also in another function
|
|
|
|
// ignore-loongarch64 FIXME
|
2020-06-04 11:13:36 +00:00
|
|
|
|
2019-12-26 15:37:48 +00:00
|
|
|
#![crate_type = "lib"]
|
2021-06-08 18:23:58 +00:00
|
|
|
#![feature(c_unwind)]
|
2019-12-26 15:37:48 +00: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()
|
|
|
|
}
|