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