From 857d37636e107baef7fb29451881293388845161 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 13 Oct 2013 06:10:03 +0200 Subject: [PATCH] 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. --- ir/iraggr.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ir/iraggr.cpp b/ir/iraggr.cpp index a065df66..2f457b1d 100644 --- a/ir/iraggr.cpp +++ b/ir/iraggr.cpp @@ -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