mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 11:26:02 +03:00
Fixed initialization of the static arrays
This commit is contained in:
parent
31472eae97
commit
3c4db7bc87
1 changed files with 8 additions and 1 deletions
|
@ -435,10 +435,17 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
|
||||||
if (arrty->ty == Tsarray)
|
if (arrty->ty == Tsarray)
|
||||||
return constarr;
|
return constarr;
|
||||||
|
|
||||||
// for dynamic array we need to make a global with the data, so we have a pointer for the dynamic array
|
// we need to make a global with the data, so we have a pointer to the array
|
||||||
// Important: don't make the gvar constant, since this const initializer might
|
// Important: don't make the gvar constant, since this const initializer might
|
||||||
// be used as an initializer for a static T[] - where modifying contents is allowed.
|
// be used as an initializer for a static T[] - where modifying contents is allowed.
|
||||||
LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, constarr->getType(), false, LLGlobalValue::InternalLinkage, constarr, ".constarray");
|
LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, constarr->getType(), false, LLGlobalValue::InternalLinkage, constarr, ".constarray");
|
||||||
|
|
||||||
|
#if DMDV2
|
||||||
|
if (arrty->ty == Tpointer)
|
||||||
|
// we need to return pointer to the static array.
|
||||||
|
return gvar;
|
||||||
|
#endif
|
||||||
|
|
||||||
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
||||||
|
|
||||||
LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue