rust/tests/ui/sepcomp/sepcomp-extern.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
532 B
Rust
Raw Normal View History

// run-pass
2014-08-01 22:45:24 +00:00
// compile-flags: -C codegen-units=3
// aux-build:sepcomp-extern-lib.rs
// Test accessing external items from multiple compilation units.
extern crate sepcomp_extern_lib;
2020-09-01 21:12:52 +00:00
extern "C" {
fn foo() -> usize;
2014-08-01 22:45:24 +00:00
}
fn call1() -> usize {
2014-08-01 22:45:24 +00:00
unsafe { foo() }
}
mod a {
pub fn call2() -> usize {
2014-08-01 22:45:24 +00:00
unsafe { ::foo() }
}
}
mod b {
pub fn call3() -> usize {
2014-08-01 22:45:24 +00:00
unsafe { ::foo() }
}
}
fn main() {
assert_eq!(call1(), 1234);
assert_eq!(a::call2(), 1234);
assert_eq!(b::call3(), 1234);
}