rust/tests/ui/c-variadic/variadic-ffi-2.rs
Tamme Dittrich 47293c1234 Check ABI target compatibility for function pointers
This check was previously only performed on functions not function pointers.

Co-authored-by: Folkert <folkert@folkertdev.nl>
2024-09-23 14:04:22 +02:00

35 lines
839 B
Rust

//@ ignore-arm stdcall isn't supported
#![feature(extended_varargs_abi_support)]
#[allow(unsupported_fn_ptr_calling_conventions)]
fn baz(f: extern "stdcall" fn(usize, ...)) {
//~^ ERROR: C-variadic function must have a compatible calling convention,
// like C, cdecl, system, aapcs, win64, sysv64 or efiapi
f(22, 44);
}
fn system(f: extern "system" fn(usize, ...)) {
f(22, 44);
}
#[cfg(target_arch = "x86_64")]
fn sysv(f: extern "sysv64" fn(usize, ...)) {
f(22, 44);
}
#[cfg(target_arch = "x86_64")]
fn win(f: extern "win64" fn(usize, ...)) {
f(22, 44);
}
#[cfg(any(
target_arch = "arm",
target_arch = "aarch64",
target_arch = "riscv32",
target_arch = "riscv64",
target_arch = "x86",
target_arch = "x86_64"
))]
fn efiapi(f: extern "efiapi" fn(usize, ...)) {
f(22, 44);
}
fn main() {}