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