diff options
author | antego <antego@users.noreply.github.com> | 2022-04-13 20:00:54 +1000 |
---|---|---|
committer | antego <antego@users.noreply.github.com> | 2022-04-21 09:02:52 +1000 |
commit | 9a56a0d10d991d066188dedb89d19119146a17a0 (patch) | |
tree | 81d6ed8b0f0e86208b436219509fa08a327fff23 | |
parent | 14dbac9a8bbc7f3cf37679e91ea56e449a64bde7 (diff) | |
download | gcc-9a56a0d10d991d066188dedb89d19119146a17a0.zip gcc-9a56a0d10d991d066188dedb89d19119146a17a0.tar.gz gcc-9a56a0d10d991d066188dedb89d19119146a17a0.tar.bz2 |
Add a test for the cfg!() macro
See #1116 and #1039
-rw-r--r-- | gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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 0000000..ac24791 --- /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 +} |