summaryrefslogtreecommitdiffstats
path: root/tests/codegen/external-no-mangle-statics.rs
blob: c6ecb7aa96abcaf2defd9c6724c04385fc768c1a (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// revisions: lib staticlib
// ignore-emscripten default visibility is hidden
// compile-flags: -O
// [lib] compile-flags: --crate-type lib
// [staticlib] compile-flags: --crate-type staticlib
// `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their
// definitions

// CHECK: @A = local_unnamed_addr constant
#[no_mangle]
static A: u8 = 0;

// CHECK: @B = local_unnamed_addr global
#[no_mangle]
static mut B: u8 = 0;

// CHECK: @C = local_unnamed_addr constant
#[no_mangle]
pub static C: u8 = 0;

// CHECK: @D = local_unnamed_addr global
#[no_mangle]
pub static mut D: u8 = 0;

mod private {
    // CHECK: @E = local_unnamed_addr constant
    #[no_mangle]
    static E: u8 = 0;

    // CHECK: @F = local_unnamed_addr global
    #[no_mangle]
    static mut F: u8 = 0;

    // CHECK: @G = local_unnamed_addr constant
    #[no_mangle]
    pub static G: u8 = 0;

    // CHECK: @H = local_unnamed_addr global
    #[no_mangle]
    pub static mut H: u8 = 0;
}

const HIDDEN: () = {
    // CHECK: @I = local_unnamed_addr constant
    #[no_mangle]
    static I: u8 = 0;

    // CHECK: @J = local_unnamed_addr global
    #[no_mangle]
    static mut J: u8 = 0;

    // CHECK: @K = local_unnamed_addr constant
    #[no_mangle]
    pub static K: u8 = 0;

    // CHECK: @L = local_unnamed_addr global
    #[no_mangle]
    pub static mut L: u8 = 0;
};

fn x() {
    // CHECK: @M = local_unnamed_addr constant
    #[no_mangle]
    static M: fn() = x;

    // CHECK: @N = local_unnamed_addr global
    #[no_mangle]
    static mut N: u8 = 0;

    // CHECK: @O = local_unnamed_addr constant
    #[no_mangle]
    pub static O: u8 = 0;

    // CHECK: @P = local_unnamed_addr global
    #[no_mangle]
    pub static mut P: u8 = 0;
}