summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-05-30 12:02:14 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-05-30 12:02:14 +0000
commitf7fe41656c317fff867335186ae848b4d45c5a75 (patch)
treec0df1620dde13404d4766775ecf685cfcffd82ea /clang/lib
parent35c01c6f2da9f7ad3aceda89bf2d33a29f3eaa28 (diff)
downloadbcm5719-llvm-f7fe41656c317fff867335186ae848b4d45c5a75.tar.gz
bcm5719-llvm-f7fe41656c317fff867335186ae848b4d45c5a75.zip
Fix constant vector init for initializer lists with an incomplete list
of elements. llvm-svn: 51769
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index ca7a580ef78..1144cf1c915 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -242,20 +242,23 @@ public:
llvm::Constant *EmitVectorInitialization(InitListExpr *ILE) {
const llvm::VectorType *VType =
cast<llvm::VectorType>(ConvertType(ILE->getType()));
- std::vector<llvm::Constant*> Elts;
- unsigned NumInitElements = ILE->getNumInits();
+ const llvm::Type *ElemTy = VType->getElementType();
+ std::vector<llvm::Constant*> Elts;
unsigned NumElements = VType->getNumElements();
+ unsigned NumInitElements = ILE->getNumInits();
+
+ unsigned NumInitableElts = std::min(NumInitElements, NumElements);
- // FIXME: Handle case in assertion correctly
- assert (NumInitElements == NumElements
- && "Unsufficient vector init elelments");
// Copy initializer elements.
unsigned i = 0;
- for (; i < NumElements; ++i) {
+ for (; i < NumInitableElts; ++i) {
llvm::Constant *C = Visit(ILE->getInit(i));
Elts.push_back(C);
}
+ for (; i < NumElements; ++i)
+ Elts.push_back(llvm::Constant::getNullValue(ElemTy));
+
return llvm::ConstantVector::get(VType, Elts);
}
OpenPOWER on IntegriCloud