Add a test for the cfg!() macro

See #1116 and #1039
This commit is contained in:
antego 2022-04-13 20:00:54 +10:00
parent 14dbac9a8b
commit 9a56a0d10d
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
// { dg-additional-options "-w -frust-cfg=A" }
// { dg-output "A\n" }
macro_rules! cfg {
() => {{}};
}
extern "C" {
fn printf(fmt: *const i8, ...);
}
fn print(s: &str) {
printf("%s\n" as *const str as *const i8, s as *const str as *const i8);
}
fn main() -> i32 {
let cfg = cfg!(A);
if cfg {
print("A");
}
let cfg = cfg!(B);
if cfg {
print("B");
}
0
}