Skip to content

Commit fc22f12

Browse files
bors[bot]antego
andauthored
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>
2 parents 14dbac9 + 9a56a0d commit fc22f12

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// { dg-additional-options "-w -frust-cfg=A" }
2+
// { dg-output "A\n" }
3+
macro_rules! cfg {
4+
() => {{}};
5+
}
6+
7+
extern "C" {
8+
fn printf(fmt: *const i8, ...);
9+
}
10+
11+
fn print(s: &str) {
12+
printf("%s\n" as *const str as *const i8, s as *const str as *const i8);
13+
}
14+
15+
16+
fn main() -> i32 {
17+
let cfg = cfg!(A);
18+
if cfg {
19+
print("A");
20+
}
21+
let cfg = cfg!(B);
22+
if cfg {
23+
print("B");
24+
}
25+
26+
0
27+
}

0 commit comments

Comments
 (0)