Fixed broken static struct member initializer

This commit is contained in:
Sebastian Graf
2013-01-29 20:08:33 +01:00
committed by David Nadlinger
parent db9edaf053
commit 5ae17a59e4
2 changed files with 12 additions and 3 deletions

View File

@@ -271,8 +271,17 @@ std::vector<llvm::Value*> DtoStructLiteralValues(const StructDeclaration* sd,
add_zeros(values, os - lastoffset - lastsize);
}
// add the expression value
values.push_back(inits[i]);
size_t repCount = 1;
// compute repCount to fill each array dimension
for (Type *varType = var->type;
varType->ty == Tsarray;
varType = varType->nextOf())
{
repCount *= static_cast<TypeSArray*>(varType)->dim->toUInteger();
}
// add the expression values
std::fill_n(std::back_inserter(values), repCount, inits[i]);
// update offsets
lastoffset = os;