The llvm element type of void arrays should be i8 and not void.

This caused DtoArrayCopyToSlice to fail when trying to get the size of
llvm-void for something like void[3] s = "abc"; inside a function.
This commit is contained in:
Christian Kamm
2009-06-12 20:39:01 +02:00
parent 25ebb3dbcd
commit 1563c14e7a

View File

@@ -184,7 +184,7 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value)
assert(arrayelemty == valuety && "ArrayInit doesn't work on elem-initialized static arrays");
args[0] = DtoBitCast(args[0], getVoidPtrType());
args[2] = DtoBitCast(args[2], getVoidPtrType());
args.push_back(DtoConstSize_t(getTypePaddedSize(DtoType(arrayelemty))));
args.push_back(DtoConstSize_t(getTypePaddedSize(DtoTypeNotVoid(arrayelemty))));
break;
default:
@@ -247,7 +247,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
// get elem type
Type* elemty = arrty->nextOf();
const LLType* llelemty = DtoType(elemty);
const LLType* llelemty = DtoTypeNotVoid(elemty);
// true if array elements differ in type, can happen with array of unions
bool mismatch = false;
@@ -367,7 +367,7 @@ void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src)
LLValue* dstarr = get_slice_ptr(dst,sz1);
LLValue* srcarr = DtoBitCast(DtoArrayPtr(src), getVoidPtrType());
const LLType* arrayelemty = DtoType(src->getType()->nextOf()->toBasetype());
const LLType* arrayelemty = DtoTypeNotVoid(src->getType()->nextOf()->toBasetype());
LLValue* sz2 = gIR->ir->CreateMul(DtoConstSize_t(getTypePaddedSize(arrayelemty)), DtoArrayLen(src), "tmp");
if (global.params.useAssert || global.params.useArrayBounds)