]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/external-no-mangle-statics.rs
Remove GlobalArenas and use Arena instead
[rust.git] / src / test / codegen / external-no-mangle-statics.rs
1 // compile-flags: -O
2 // `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their
3 // definitions
4
5 #![crate_type = "lib"]
6 #![no_std]
7
8 // CHECK: @A = local_unnamed_addr constant
9 #[no_mangle]
10 static A: u8 = 0;
11
12 // CHECK: @B = local_unnamed_addr global
13 #[no_mangle]
14 static mut B: u8 = 0;
15
16 // CHECK: @C = local_unnamed_addr constant
17 #[no_mangle]
18 pub static C: u8 = 0;
19
20 // CHECK: @D = local_unnamed_addr global
21 #[no_mangle]
22 pub static mut D: u8 = 0;
23
24 mod private {
25     // CHECK: @E = local_unnamed_addr constant
26     #[no_mangle]
27     static E: u8 = 0;
28
29     // CHECK: @F = local_unnamed_addr global
30     #[no_mangle]
31     static mut F: u8 = 0;
32
33     // CHECK: @G = local_unnamed_addr constant
34     #[no_mangle]
35     pub static G: u8 = 0;
36
37     // CHECK: @H = local_unnamed_addr global
38     #[no_mangle]
39     pub static mut H: u8 = 0;
40 }
41
42 const HIDDEN: () = {
43     // CHECK: @I = local_unnamed_addr constant
44     #[no_mangle]
45     static I: u8 = 0;
46
47     // CHECK: @J = local_unnamed_addr global
48     #[no_mangle]
49     static mut J: u8 = 0;
50
51     // CHECK: @K = local_unnamed_addr constant
52     #[no_mangle]
53     pub static K: u8 = 0;
54
55     // CHECK: @L = local_unnamed_addr global
56     #[no_mangle]
57     pub static mut L: u8 = 0;
58 };
59
60 // The surrounding item should not accidentally become external
61 fn x() {
62     // CHECK: @M = local_unnamed_addr constant
63     #[no_mangle]
64     static M: fn() = x;
65
66     // CHECK: @N = local_unnamed_addr global
67     #[no_mangle]
68     static mut N: u8 = 0;
69
70     // CHECK: @O = local_unnamed_addr constant
71     #[no_mangle]
72     pub static O: u8 = 0;
73
74     // CHECK: @P = local_unnamed_addr global
75     #[no_mangle]
76     pub static mut P: u8 = 0;
77 }
78 // CHECK: define internal void @_ZN26external_no_mangle_statics1x{{.*$}}