Debian Codegraph @

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

raw
1 // { dg-additional-options "-w -frust-cfg=A" }
2 // { dg-output "test1\r*\ntest2\r*\n" }
3 extern "C" {
4 fn printf(s: *const i8, ...);
5 }
6
7 struct Foo(i32);
8 impl Foo {
9 #[cfg(A)]
10 fn test(&self) {
11 unsafe {
12 let a = "test1\n\0";
13 let b = a as *const str;
14 let c = b as *const i8;
15
16 printf(c);
17 }
18 }
19
20 #[cfg(not(B))]
21 fn test2(&self) {
22 unsafe {
23 let a = "test2\n\0";
24 let b = a as *const str;
25 let c = b as *const i8;
26
27 printf(c);
28 }
29 }
30 }
31
32 fn main() -> i32 {
33 let a = Foo(123);
34 a.test();
35 a.test2();
36
37 0
38 }