From 1563c14e7af0dc1512829896396070bf01fb96c4 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 12 Jun 2009 20:39:01 +0200 Subject: [PATCH] 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. --- gen/arrays.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gen/arrays.cpp b/gen/arrays.cpp index d5e6213c..040b36ae 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -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)