Detect a missing global before trying to const init it.

This commit is contained in:
Christian Kamm
2008-10-01 20:32:12 +02:00
parent 656b89db0f
commit 32c4f92334

View File

@@ -128,7 +128,6 @@ DValue* VarExp::toElem(IRState* p)
// take care of forward references of global variables
if (vd->isDataseg() || (vd->storage_class & STCextern)) {
vd->toObjFile(0); // TODO: multiobj
DtoConstInitGlobal(vd);
}
if (!vd->ir.isSet() || !vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) {
error("global variable %s not resolved", vd->toChars());
@@ -136,6 +135,9 @@ DValue* VarExp::toElem(IRState* p)
Logger::cout() << "unresolved global had type: " << *DtoType(vd->type) << '\n';
fatal();
}
if (vd->isDataseg() || (vd->storage_class & STCextern)) {
DtoConstInitGlobal(vd);
}
return new DVarValue(type, vd, vd->ir.getIrValue());
}
}