mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 01:20:51 +03:00
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
This commit is contained in:
parent
c53562ee10
commit
0bddb2568f
1 changed files with 16 additions and 1 deletions
|
@ -969,7 +969,22 @@ LLConstant* DtoConstInitializer(Type* type, Initializer* init)
|
|||
if (!init)
|
||||
{
|
||||
Logger::println("const default initializer for %s", type->toChars());
|
||||
_init = type->defaultInit()->toConstElem(gIR);
|
||||
|
||||
if(type->ty == Tsarray)
|
||||
{
|
||||
Logger::println("type is a static array, building constant array initializer");
|
||||
TypeSArray* arrtype = (TypeSArray*)type;
|
||||
Type* elemtype = type->next;
|
||||
|
||||
integer_t arraydim;
|
||||
arraydim = arrtype->dim->toInteger();
|
||||
|
||||
std::vector<LLConstant*> inits(arraydim, elemtype->defaultInit()->toConstElem(gIR));
|
||||
const LLArrayType* arrty = LLArrayType::get(DtoType(elemtype),arraydim);
|
||||
_init = LLConstantArray::get(arrty, inits);
|
||||
}
|
||||
else
|
||||
_init = type->defaultInit()->toConstElem(gIR);
|
||||
}
|
||||
else if (ExpInitializer* ex = init->isExpInitializer())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue