Handle void[0] struct/class members.

This was also broken before the symbol emission
changes; we just accidentally managed to avoid
the only occurence in the standard library tests.
This commit is contained in:
David Nadlinger
2013-10-13 06:10:03 +02:00
parent 4fee629c4d
commit 857d37636e

View File

@@ -205,14 +205,19 @@ LLConstant* get_default_initializer(VarDeclaration* vd, Initializer* init)
{
return DtoConstInitializer(init->loc, vd->type, init);
}
else if (vd->init)
if (vd->init)
{
return DtoConstInitializer(vd->init->loc, vd->type, vd->init);
}
else
if (vd->type->size(vd->loc) == 0)
{
return DtoConstExpInit(vd->loc, vd->type, vd->type->defaultInit(vd->loc));
// We need to be able to handle void[0] struct members even if void has
// no default initializer.
return llvm::ConstantPointerNull::get(getPtrToType(DtoType(vd->type)));
}
return DtoConstExpInit(vd->loc, vd->type, vd->type->defaultInit(vd->loc));
}
// return a constant array of type arrTypeD initialized with a constant value, or that constant value