mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-29 22:50:53 +03:00
Do not emit globals with void initializer as LLVM constants
Fixes things like `const(Foo) f = void; static shared this() { f = …; }`.
This commit is contained in:
parent
f336ff9ee5
commit
f7c3fc4ef3
1 changed files with 5 additions and 1 deletions
|
@ -929,7 +929,11 @@ void DtoResolveVariable(VarDeclaration* vd)
|
|||
Logger::println("parent: null");
|
||||
}
|
||||
|
||||
const bool isLLConst = (vd->isConst() || vd->isImmutable()) && vd->init;
|
||||
// If a const/immutable value has a proper initializer (not "= void"),
|
||||
// it cannot be assigned again in a static constructor. Thus, we can
|
||||
// emit it as read-only data.
|
||||
const bool isLLConst = (vd->isConst() || vd->isImmutable()) &&
|
||||
vd->init && !vd->init->isVoidInitializer();
|
||||
|
||||
assert(!vd->ir.isInitialized());
|
||||
if (gIR->dmodule)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue