Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 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 | |
Dave Huseby | 5387189 | 2015-03-23 19:48:42 | [diff] [blame] | 11 | // ignore-bitrig |
Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 12 | // compile-flags: -C codegen-units=3 |
| 13 | |
| 14 | // Test references to static items across compilation units. |
| 15 | |
Brian Anderson | 8c93a79 | 2015-03-22 20:13:15 | [diff] [blame] | 16 | |
Alex Crichton | 43bfaa4 | 2015-03-26 00:06:52 | [diff] [blame] | 17 | fn pad() -> usize { 0 } |
Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 18 | |
Alex Crichton | 43bfaa4 | 2015-03-26 00:06:52 | [diff] [blame] | 19 | const ONE: usize = 1; |
Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 20 | |
| 21 | mod 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 Crichton | 43bfaa4 | 2015-03-26 00:06:52 | [diff] [blame] | 25 | fn pad() -> usize { 0 } |
Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 26 | |
Alex Crichton | 43bfaa4 | 2015-03-26 00:06:52 | [diff] [blame] | 27 | pub static THREE: usize = ::ONE + ::a::TWO; |
Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | mod a { |
Alex Crichton | 43bfaa4 | 2015-03-26 00:06:52 | [diff] [blame] | 31 | fn pad() -> usize { 0 } |
Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 32 | |
Alex Crichton | 43bfaa4 | 2015-03-26 00:06:52 | [diff] [blame] | 33 | pub const TWO: usize = ::ONE + ::ONE; |
Stuart Pernsteiner | 4b70269 | 2014-08-01 22:45:24 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | fn main() { |
| 37 | assert_eq!(ONE, 1); |
| 38 | assert_eq!(a::TWO, 2); |
| 39 | assert_eq!(b::THREE, 3); |
| 40 | } |