aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/macros31.rs
blob: 0a256c36a4fcdd736764ecb13d2564f137174843 (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
28
29
30
31
32
33
34
// { dg-additional-options "-w -frust-cfg=A" }
// { dg-output "A\r*\nB\r*\n" }
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
macro_rules! cfg {
    () => {{}};
}

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

fn print(s: &str) {
    unsafe {
        printf(
            "%s\n" as *const str as *const i8,
            s as *const str as *const i8,
        );
    }
}

fn main() -> i32 {
    let cfg = cfg!(A) || cfg!(B);
    if cfg {
        print("A");
    }
    let cfg = cfg!(A) && cfg!(B);
    if !cfg {
        print("B");
    }

    0
}