diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-21 08:13:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 08:13:19 +0000 |
commit | fc22f12c9c707b258f35a1bab0e8154441b972b8 (patch) | |
tree | 81d6ed8b0f0e86208b436219509fa08a327fff23 | |
parent | 14dbac9a8bbc7f3cf37679e91ea56e449a64bde7 (diff) | |
parent | 9a56a0d10d991d066188dedb89d19119146a17a0 (diff) | |
download | gcc-fc22f12c9c707b258f35a1bab0e8154441b972b8.zip gcc-fc22f12c9c707b258f35a1bab0e8154441b972b8.tar.gz gcc-fc22f12c9c707b258f35a1bab0e8154441b972b8.tar.bz2 |
Merge #1119
1119: Add a test for the cfg!() macro r=CohenArthur a=antego
See #1116 and #1039
Adding a test for the cfg!() macro. The compilation of the test fails with the message:
```
fatal error: Failed to lower expr: [MacroInvocation:
outer attributes: none
cfg!((A))
has semicolon: false]
compilation terminated.
```
Co-authored-by: antego <antego@users.noreply.github.com>
-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 +} |