diff options
| author | bors <bors@rust-lang.org> | 2025-09-13 23:02:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-09-13 23:02:12 +0000 |
| commit | a015919e54c60b1b2bec7a98dec478cfc4a48f4e (patch) | |
| tree | 8a1fc4a0c27ec87edc0d0449bb4fa3dab130bab6 /tests/codegen-llvm/cffi/c-variadic-inline.rs | |
| parent | 02c7b1a7ac1d739663878030510508372e46f254 (diff) | |
| parent | da1c27df16075d9ebb28a94cf9b400e89c476233 (diff) | |
| download | rust-a015919e54c60b1b2bec7a98dec478cfc4a48f4e.tar.gz rust-a015919e54c60b1b2bec7a98dec478cfc4a48f4e.zip | |
Auto merge of #146526 - jhpratt:rollup-afb1dgo, r=jhpratt
Rollup of 8 pull requests Successful merges: - rust-lang/rust#113095 (Document `become` keyword) - rust-lang/rust#146159 (Some hygiene doc improvements) - rust-lang/rust#146171 (tidy: check that error messages don't start with a capitalized letter) - rust-lang/rust#146419 (Update the arm-* and aarch64-* platform docs.) - rust-lang/rust#146473 (Revert "Constify SystemTime methods") - rust-lang/rust#146506 (Fix small typo in check-cfg.md) - rust-lang/rust#146517 (fix Condvar::wait_timeout docs) - rust-lang/rust#146521 (document `core::ffi::VaArgSafe`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen-llvm/cffi/c-variadic-inline.rs')
| -rw-r--r-- | tests/codegen-llvm/cffi/c-variadic-inline.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/codegen-llvm/cffi/c-variadic-inline.rs b/tests/codegen-llvm/cffi/c-variadic-inline.rs new file mode 100644 index 00000000000..369b7e571ca --- /dev/null +++ b/tests/codegen-llvm/cffi/c-variadic-inline.rs @@ -0,0 +1,47 @@ +//@ compile-flags: -C opt-level=3 +#![feature(c_variadic)] + +// Test that the inline attributes are accepted on C-variadic functions. +// +// Currently LLVM is unable to inline C-variadic functions, but that is valid because despite +// the name even `#[inline(always)]` is just a hint. + +#[inline(always)] +unsafe extern "C" fn inline_always(mut ap: ...) -> u32 { + ap.arg::<u32>() +} + +#[inline] +unsafe extern "C" fn inline(mut ap: ...) -> u32 { + ap.arg::<u32>() +} + +#[inline(never)] +unsafe extern "C" fn inline_never(mut ap: ...) -> u32 { + ap.arg::<u32>() +} + +#[cold] +unsafe extern "C" fn cold(mut ap: ...) -> u32 { + ap.arg::<u32>() +} + +#[unsafe(no_mangle)] +#[inline(never)] +fn helper() { + // CHECK-LABEL: helper + // CHECK-LABEL: call c_variadic_inline::inline_always + // CHECK-LABEL: call c_variadic_inline::inline + // CHECK-LABEL: call c_variadic_inline::inline_never + // CHECK-LABEL: call c_variadic_inline::cold + unsafe { + inline_always(1); + inline(2); + inline_never(3); + cold(4); + } +} + +fn main() { + helper() +} |
