-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <pierre-emmanuel.patry@embecosm.com>
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |