mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 11:26:02 +03:00
[svn r227] Fixed: crash in lifetime.d when resizing array of AAs by .length assignment.
This commit is contained in:
parent
a954f06e90
commit
6b735db510
4 changed files with 18 additions and 10 deletions
|
@ -2333,6 +2333,11 @@ Expression *TypeAArray::defaultInit(Loc loc)
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TypeAArray::isZeroInit()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int TypeAArray::checkBoolean()
|
int TypeAArray::checkBoolean()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -360,6 +360,7 @@ struct TypeAArray : TypeArray
|
||||||
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
|
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
|
||||||
Expression *defaultInit(Loc loc);
|
Expression *defaultInit(Loc loc);
|
||||||
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
|
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
|
||||||
|
int isZeroInit();
|
||||||
int checkBoolean();
|
int checkBoolean();
|
||||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||||
int hasPointers();
|
int hasPointers();
|
||||||
|
|
|
@ -545,7 +545,10 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, DValue* newdim)
|
||||||
assert(arrayType);
|
assert(arrayType);
|
||||||
assert(arrayType->toBasetype()->ty == Tarray);
|
assert(arrayType->toBasetype()->ty == Tarray);
|
||||||
|
|
||||||
bool zeroInit = arrayType->toBasetype()->nextOf()->isZeroInit();
|
// decide on what runtime function to call based on whether the type is zero initialized
|
||||||
|
bool zeroInit = arrayType->toBasetype()->next->isZeroInit();
|
||||||
|
|
||||||
|
// call runtime
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_arraysetlengthT" : "_d_arraysetlengthiT" );
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_arraysetlengthT" : "_d_arraysetlengthiT" );
|
||||||
|
|
||||||
llvm::SmallVector<llvm::Value*,4> args;
|
llvm::SmallVector<llvm::Value*,4> args;
|
||||||
|
|
|
@ -514,9 +514,8 @@ body
|
||||||
|
|
||||||
debug(PRINTF)
|
debug(PRINTF)
|
||||||
{
|
{
|
||||||
printf("_d_arraysetlengthT(p = %p, sizeelem = %d, newlength = %d)\n", p, sizeelem, newlength);
|
printf("_d_arraysetlengthT(sizeelem = %d, newlength = %d)\n", sizeelem, newlength);
|
||||||
if (p)
|
printf("\tp.data = %p, p.length = %d\n", pdata, plength);
|
||||||
printf("\tp.data = %p, p.length = %d\n", pdata, plength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newlength)
|
if (newlength)
|
||||||
|
@ -602,8 +601,9 @@ in
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
byte* newdata;
|
byte* newdata;
|
||||||
size_t sizeelem = ti.next.tsize();
|
TypeInfo tinext = ti.next;
|
||||||
void[] initializer = ti.next.init();
|
size_t sizeelem = tinext.tsize();
|
||||||
|
void[] initializer = tinext.init();
|
||||||
size_t initsize = initializer.length;
|
size_t initsize = initializer.length;
|
||||||
|
|
||||||
assert(sizeelem);
|
assert(sizeelem);
|
||||||
|
@ -613,9 +613,8 @@ body
|
||||||
|
|
||||||
debug(PRINTF)
|
debug(PRINTF)
|
||||||
{
|
{
|
||||||
printf("_d_arraysetlengthiT(p = %p, sizeelem = %d, newlength = %d, initsize = %d)\n", p, sizeelem, newlength, initsize);
|
printf("_d_arraysetlengthiT(sizeelem = %d, newlength = %d, initsize = %d)\n", sizeelem, newlength, initsize);
|
||||||
if (p)
|
printf("\tp.data = %p, p.length = %d\n", pdata, plength);
|
||||||
printf("\tp.data = %p, p.length = %d\n", pdata, plength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newlength)
|
if (newlength)
|
||||||
|
@ -668,7 +667,7 @@ body
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newdata = cast(byte *)gc_malloc(newsize + 1, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0);
|
newdata = cast(byte *)gc_malloc(newsize + 1, !(tinext.flags() & 1) ? BlkAttr.NO_SCAN : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto q = initializer.ptr; // pointer to initializer
|
auto q = initializer.ptr; // pointer to initializer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue