]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/sepcomp-statics.rs
26a5c4d1c5026cb6b9dd4d0c8e634dfb813be9e8
[rustc.git] / src / test / run-pass / sepcomp-statics.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -C codegen-units=3
12
13 // Test references to static items across compilation units.
14
15 fn pad() -> uint { 0 }
16
17 const ONE: uint = 1;
18
19 mod b {
20 // Separate compilation always switches to the LLVM module with the fewest
21 // instructions. Make sure we have some instructions in this module so
22 // that `a` and `b` don't go into the same compilation unit.
23 fn pad() -> uint { 0 }
24
25 pub static THREE: uint = ::ONE + ::a::TWO;
26 }
27
28 mod a {
29 fn pad() -> uint { 0 }
30
31 pub const TWO: uint = ::ONE + ::ONE;
32 }
33
34 fn main() {
35 assert_eq!(ONE, 1);
36 assert_eq!(a::TWO, 2);
37 assert_eq!(b::THREE, 3);
38 }
39