aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/macros10.rs
blob: 4f976f0b317cb07f558b19e29d047db05bf1a38a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// { dg-output "18\r*\n" }
extern "C" {
    fn printf(s: *const i8, ...);
}

fn print_int(value: i32) {
    let s = "%d\n\0" as *const str as *const i8;
    unsafe {
        printf(s, value);
    }
}

macro_rules! add_exprs {
    ($($e:expr)*) => (0 $(+ $e)*)
}

fn main() -> i32 {
    // 1 + 2 + 15 => 18
    print_int(add_exprs!(1 2 15));

    0
}