aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/cfg3.rs
blob: 97a8fb8e4610026bf1b3ed31422b3f31abab836b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// { dg-additional-options "-w -frust-cfg=A" }
// { dg-output "test1\r*\n" }
extern "C" {
    fn printf(s: *const i8, ...);
}

struct Foo(i32);
impl Foo {
    #[cfg(A)]
    fn test(&self) {
        unsafe {
            let a = "test1\n\0";
            let b = a as *const str;
            let c = b as *const i8;

            printf(c);
        }
    }

    #[cfg(B)]
    fn test(&self) {
        unsafe {
            let a = "test2\n\0";
            let b = a as *const str;
            let c = b as *const i8;

            printf(c);
        }
    }
}

fn main() -> i32 {
    let a = Foo(123);
    a.test();

    0
}