Debian Codegraph @

gcc/testsuite/rust/execute/torture/macros31.rs

raw
1 // { dg-additional-options "-w -frust-cfg=A" }
2 // { dg-output "A\r*\nB\r*\n" }
3 #![feature(rustc_attrs)]
4
5 #[rustc_builtin_macro]
6 macro_rules! cfg {
7 () => {{}};
8 }
9
10 extern "C" {
11 fn printf(fmt: *const i8, ...);
12 }
13
14 fn print(s: &str) {
15 unsafe {
16 printf(
17 "%s\n" as *const str as *const i8,
18 s as *const str as *const i8,
19 );
20 }
21 }
22
23 fn main() -> i32 {
24 let cfg = cfg!(A) || cfg!(B);
25 if cfg {
26 print("A");
27 }
28 let cfg = cfg!(A) && cfg!(B);
29 if !cfg {
30 print("B");
31 }
32
33 0
34 }