2021-11-19 21:33:29 -06:00
|
|
|
// build-pass
|
2021-11-20 18:29:15 -06:00
|
|
|
// compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes
|
2021-11-19 21:33:29 -06:00
|
|
|
|
|
|
|
// This test declares globals by the same name with different types, which
|
|
|
|
// caused problems because Module::getOrInsertGlobal would return a Constant*
|
|
|
|
// bitcast instead of a GlobalVariable* that could access linkage/visibility.
|
|
|
|
// In alt builds with LLVM assertions this would fail:
|
|
|
|
//
|
|
|
|
// rustc: /checkout/src/llvm-project/llvm/include/llvm/Support/Casting.h:269:
|
|
|
|
// typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = llvm::GlobalValue, Y = llvm::Value]:
|
|
|
|
// Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
|
|
|
|
//
|
|
|
|
// In regular builds, the bad cast was UB, like "Invalid LLVMRustVisibility value!"
|
|
|
|
|
2023-05-19 04:14:55 -05:00
|
|
|
#![allow(dropping_copy_types)]
|
2023-03-29 15:18:20 -05:00
|
|
|
|
2021-11-19 21:33:29 -06:00
|
|
|
pub mod before {
|
|
|
|
#[no_mangle]
|
|
|
|
pub static GLOBAL1: [u8; 1] = [1];
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod inner {
|
|
|
|
extern "C" {
|
|
|
|
pub static GLOBAL1: u8;
|
|
|
|
pub static GLOBAL2: u8;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn call() {
|
|
|
|
drop(unsafe { (GLOBAL1, GLOBAL2) });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod after {
|
|
|
|
#[no_mangle]
|
|
|
|
pub static GLOBAL2: [u8; 1] = [2];
|
|
|
|
}
|