blob: 8cda469a88bf5682e1b15ae72295c558bfbc0b55 [file] [log] [blame]
Stuart Pernsteiner4b702692014-08-01 22:45:241// 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
Dave Huseby53871892015-03-23 19:48:4211// ignore-bitrig
Stuart Pernsteiner4b702692014-08-01 22:45:2412// compile-flags: -C codegen-units=3
13
14// Test references to static items across compilation units.
15
Brian Anderson8c93a792015-03-22 20:13:1516
Alex Crichton43bfaa42015-03-26 00:06:5217fn pad() -> usize { 0 }
Stuart Pernsteiner4b702692014-08-01 22:45:2418
Alex Crichton43bfaa42015-03-26 00:06:5219const ONE: usize = 1;
Stuart Pernsteiner4b702692014-08-01 22:45:2420
21mod b {
22 // Separate compilation always switches to the LLVM module with the fewest
23 // instructions. Make sure we have some instructions in this module so
24 // that `a` and `b` don't go into the same compilation unit.
Alex Crichton43bfaa42015-03-26 00:06:5225 fn pad() -> usize { 0 }
Stuart Pernsteiner4b702692014-08-01 22:45:2426
Alex Crichton43bfaa42015-03-26 00:06:5227 pub static THREE: usize = ::ONE + ::a::TWO;
Stuart Pernsteiner4b702692014-08-01 22:45:2428}
29
30mod a {
Alex Crichton43bfaa42015-03-26 00:06:5231 fn pad() -> usize { 0 }
Stuart Pernsteiner4b702692014-08-01 22:45:2432
Alex Crichton43bfaa42015-03-26 00:06:5233 pub const TWO: usize = ::ONE + ::ONE;
Stuart Pernsteiner4b702692014-08-01 22:45:2434}
35
36fn main() {
37 assert_eq!(ONE, 1);
38 assert_eq!(a::TWO, 2);
39 assert_eq!(b::THREE, 3);
40}