Skip to content

Commit 25652e2

Browse files
P-E-Pphilberty
authored andcommitted
Add named variadic argument test
Variadic arguments may have a name or a pattern. This commit provides two new tests in order to ensure their correct behavior. gcc/testsuite/ChangeLog: * rust/compile/pattern_variadic.rs: New test. * rust/execute/torture/named_variadic.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
1 parent 5b017d2 commit 25652e2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extern "C" {
2+
fn printf(fmt: *const i8, _: ...);
3+
}
4+
5+
fn main() -> i32 {
6+
unsafe {
7+
printf(
8+
"%s" as *const str as *const i8,
9+
"Message" as *const str as *const i8,
10+
);
11+
}
12+
13+
0
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// { dg-output "Named variadic" }
2+
3+
extern "C" {
4+
fn printf(fmt: *const i8, variadic: ...);
5+
}
6+
7+
fn print(s: &str) {
8+
unsafe {
9+
printf(
10+
"%s" as *const str as *const i8,
11+
s as *const str as *const i8,
12+
);
13+
}
14+
}
15+
16+
fn main() -> i32 {
17+
print("Named variadic");
18+
19+
0
20+
}

0 commit comments

Comments
 (0)