mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Workaround for AA literal initialization ICE.
Just executing toConstElem speculatively in AssocArrayLiteralExp::toElem probably isn't the best idea anyway, I would not be surprised if there are other similar bugs. GitHub: Fixes #248.
This commit is contained in:
12
gen/toir.cpp
12
gen/toir.cpp
@@ -1293,6 +1293,18 @@ LLConstant* AddrExp::toConstElem(IRState* p)
|
||||
// global variable
|
||||
if (VarDeclaration* vd = vexp->var->isVarDeclaration())
|
||||
{
|
||||
if (!vd->isDataseg())
|
||||
{
|
||||
// Not sure if this can be triggered from user code, but it is
|
||||
// needed for the current hacky implementation of
|
||||
// AssocArrayLiteralExp::toElem, which requires on error
|
||||
// gagging to check for constantness of the initializer.
|
||||
error("cannot use address of non-global variable '%s' "
|
||||
"as constant initializer", vd->toChars());
|
||||
if (!global.gag) fatal();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vd->codegen(Type::sir);
|
||||
LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue());
|
||||
assert(llc);
|
||||
|
||||
Submodule tests/d2/dmd-testsuite updated: a4cc3344bb...c962f5df8c
Reference in New Issue
Block a user