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>
This commit is contained in:
bors[bot] 2022-04-21 08:13:19 +00:00 committed by GitHub
commit fc22f12c9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}