aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/macros22.rs
blob: 60ffae145edf38cce1ff2fa8adb04152bf441add (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// { dg-output "1\r*\n2\r*\nNaN\r*\n3\r*\n" }

macro_rules! print_num {
    ($l:literal) => {{
        unsafe {
            printf("%d\n\0" as *const str as *const i8, $l);
        }
    }};
}

extern "C" {
    fn printf(s: *const i8, ...);
}

// Check to make sure that expanding macros does not break the flow of calls
fn main() -> i32 {
    print_num!(1);
    print_num!(2);

    unsafe {
        printf("NaN\n\0" as *const str as *const i8);
    }

    print_num!(3);

    0
}