diff --git a/gcc/testsuite/rust/compile/pattern_variadic.rs b/gcc/testsuite/rust/compile/pattern_variadic.rs new file mode 100644 index 000000000000..2932b70f5b47 --- /dev/null +++ b/gcc/testsuite/rust/compile/pattern_variadic.rs @@ -0,0 +1,14 @@ +extern "C" { + fn printf(fmt: *const i8, _: ...); +} + +fn main() -> i32 { + unsafe { + printf( + "%s" as *const str as *const i8, + "Message" as *const str as *const i8, + ); + } + + 0 +} diff --git a/gcc/testsuite/rust/execute/torture/named_variadic.rs b/gcc/testsuite/rust/execute/torture/named_variadic.rs new file mode 100644 index 000000000000..d9b59cff41c0 --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/named_variadic.rs @@ -0,0 +1,20 @@ +// { dg-output "Named variadic" } + +extern "C" { + fn printf(fmt: *const i8, variadic: ...); +} + +fn print(s: &str) { + unsafe { + printf( + "%s" as *const str as *const i8, + s as *const str as *const i8, + ); + } +} + +fn main() -> i32 { + print("Named variadic"); + + 0 +}