gcc/testsuite/rust/execute/torture/cfg2.rs
raw| 1 | // { dg-additional-options "-w -frust-cfg=A" } |
| 2 | // { dg-output "test1\r*\n" } |
| 3 | extern "C" { |
| 4 | fn printf(s: *const i8, ...); |
| 5 | } |
| 6 | |
| 7 | fn test() { |
| 8 | #[cfg(A)] |
| 9 | unsafe { |
| 10 | let a = "test1\n\0"; |
| 11 | let b = a as *const str; |
| 12 | let c = b as *const i8; |
| 13 | |
| 14 | printf(c); |
| 15 | } |
| 16 | |
| 17 | #[cfg(B)] |
| 18 | unsafe { |
| 19 | let a = "test2\n\0"; |
| 20 | let b = a as *const str; |
| 21 | let c = b as *const i8; |
| 22 | |
| 23 | printf(c); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | fn main() -> i32 { |
| 28 | test(); |
| 29 | |
| 30 | 0 |
| 31 | } |