rust/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.rs
2021-12-24 12:02:23 +01:00

30 lines
822 B
Rust

// revisions: no_cache cache fn_ptr
#[no_mangle]
fn foo() {}
fn main() {
#[cfg(any(cache, fn_ptr))]
extern "Rust" {
fn foo();
}
#[cfg(fn_ptr)]
unsafe { std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)() }
//[fn_ptr]~^ ERROR calling a function with calling convention Rust using calling convention C
// `Instance` caching should not suppress ABI check.
#[cfg(cache)]
unsafe { foo() }
{
#[cfg_attr(any(cache, fn_ptr), allow(clashing_extern_declarations))]
extern "C" {
fn foo();
}
unsafe { foo() }
//[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
}
}