2022-07-08 16:08:32 +00:00
|
|
|
//@revisions: no_cache cache fn_ptr
|
2021-04-16 05:19:23 +08:00
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
fn foo() {}
|
|
|
|
|
|
|
|
fn main() {
|
2021-05-31 11:05:04 +08:00
|
|
|
#[cfg(any(cache, fn_ptr))]
|
|
|
|
extern "Rust" {
|
|
|
|
fn foo();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(fn_ptr)]
|
2022-06-21 22:56:50 -07:00
|
|
|
unsafe {
|
2022-06-21 23:03:34 -07:00
|
|
|
std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)();
|
2022-07-11 11:44:55 +00:00
|
|
|
//[fn_ptr]~^ ERROR: calling a function with calling convention Rust using calling convention C
|
2022-06-21 22:56:50 -07:00
|
|
|
}
|
2021-05-31 11:05:04 +08:00
|
|
|
|
|
|
|
// `Instance` caching should not suppress ABI check.
|
2021-04-16 05:19:23 +08:00
|
|
|
#[cfg(cache)]
|
2022-06-21 22:56:50 -07:00
|
|
|
unsafe {
|
2022-06-21 23:03:34 -07:00
|
|
|
foo();
|
2022-06-21 22:56:50 -07:00
|
|
|
}
|
2021-05-31 11:05:04 +08:00
|
|
|
|
2021-04-16 05:19:23 +08:00
|
|
|
{
|
2021-05-31 11:05:04 +08:00
|
|
|
#[cfg_attr(any(cache, fn_ptr), allow(clashing_extern_declarations))]
|
|
|
|
extern "C" {
|
2021-04-16 05:19:23 +08:00
|
|
|
fn foo();
|
|
|
|
}
|
2022-06-21 23:03:34 -07:00
|
|
|
unsafe {
|
|
|
|
foo();
|
2022-07-11 11:44:55 +00:00
|
|
|
//[no_cache]~^ ERROR: calling a function with calling convention Rust using calling convention C
|
|
|
|
//[cache]~| ERROR: calling a function with calling convention Rust using calling convention C
|
2022-06-21 23:03:34 -07:00
|
|
|
}
|
2021-04-16 05:19:23 +08:00
|
|
|
}
|
|
|
|
}
|