Fix for issue #419.

The vector type was not handled in `DtoConstArrayInitializer()`.
This commit is contained in:
kai
2013-07-01 07:30:27 +02:00
parent 1a8c3588b5
commit fa40b29160
2 changed files with 13 additions and 4 deletions

View File

@@ -284,7 +284,11 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
}
// get elem type
Type* elemty = arrty->nextOf();
Type* elemty;
if (arrty->ty == Tvector)
elemty = static_cast<TypeVector *>(arrty)->elementType();
else
elemty = arrty->nextOf();
LLType* llelemty = i1ToI8(voidToI8(DtoType(elemty)));
// true if array elements differ in type, can happen with array of unions
@@ -349,12 +353,17 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
if (mismatch)
constarr = LLConstantStruct::getAnon(gIR->context(), initvals); // FIXME should this pack?
else
constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals);
{
if (arrty->ty == Tvector)
constarr = llvm::ConstantVector::get(initvals);
else
constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals);
}
// std::cout << "constarr: " << *constarr << std::endl;
// if the type is a static array, we're done
if (arrty->ty == Tsarray)
if (arrty->ty == Tsarray || arrty->ty == Tvector)
return constarr;
// we need to make a global with the data, so we have a pointer to the array