From 9a56a0d10d991d066188dedb89d19119146a17a0 Mon Sep 17 00:00:00 2001 From: antego Date: Wed, 13 Apr 2022 20:00:54 +1000 Subject: [PATCH] Add a test for the cfg!() macro See #1116 and #1039 --- .../rust/execute/torture/builtin_macro_cfg.rs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs new file mode 100644 index 00000000000..ac24791bd6a --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs @@ -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 +}