Skip to content

Commit d0d4dcf

Browse files
committed
macro: Add repetition execution test cases
1 parent af789a7 commit d0d4dcf

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// { dg-output "any\nany\nany\nany\nany\n" }
1+
// { dg-output "any\nany\nany\n" }
22
extern "C" {
33
fn printf(s: *const i8, ...);
44
}
@@ -8,17 +8,19 @@ fn f() {
88
let s_p = r_s as *const str;
99
let c_p = s_p as *const i8;
1010

11-
printf(c_p);
11+
unsafe { printf(c_p); }
1212
}
1313

1414
macro_rules! any {
1515
($($a:expr)*) => {
16-
$($a;)*
16+
f()
1717
}
1818
}
1919

20-
fn main() {
21-
any!(); // valid, but does not print anything
22-
any!(f() f());
23-
any!(f() f() f());
20+
fn main() -> i32 {
21+
any!();
22+
any!(a + b);
23+
any!(a + b 14 "gcc");
24+
25+
0
2426
}

gcc/testsuite/rust/execute/xfail/macro5.rs renamed to gcc/testsuite/rust/execute/torture/macros8.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ macro_rules! zero_or_one {
1717
}
1818
}
1919

20-
fn main() {
20+
fn main() -> i32 {
2121
zero_or_one!();
2222
zero_or_one!(f());
23+
24+
0
2325
}

gcc/testsuite/rust/execute/xfail/macro6.rs renamed to gcc/testsuite/rust/execute/torture/macros9.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ fn f() {
1313

1414
macro_rules! one_or_more {
1515
($($a:expr)+) => {
16-
$($a;)+
16+
f()
1717
}
1818
}
1919

20-
fn main() {
20+
fn main() -> i32 {
2121
one_or_more!(f());
2222
one_or_more!(f() f());
23+
one_or_more!(f() f() 15 + 12);
24+
25+
0
2326
}

0 commit comments

Comments
 (0)