aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/cfg4.rs
blob: 97026d902d0fd7c04caaccc6497d40ce8c07a55b (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
38
// { dg-additional-options "-w -frust-cfg=A" }
// { dg-output "test1\r*\ntest2\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(not(B))]
    fn test2(&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();
    a.test2();

    0
}