diff options
Diffstat (limited to 'lib/CodeGen/CGExprComplex.cpp')
-rw-r--r-- | lib/CodeGen/CGExprComplex.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 5a752a1830..a92a7ad33e 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -738,10 +738,17 @@ ComplexPairTy ComplexExprEmitter::VisitInitListExpr(InitListExpr *E) { Ignore = TestAndClearIgnoreImag(); (void)Ignore; assert (Ignore == false && "init list ignored"); - if (E->getNumInits()) + + if (E->getNumInits() == 2) { + llvm::Value *Real = CGF.EmitScalarExpr(E->getInit(0)); + llvm::Value *Imag = CGF.EmitScalarExpr(E->getInit(1)); + return ComplexPairTy(Real, Imag); + } else if (E->getNumInits() == 1) { return Visit(E->getInit(0)); + } // Empty init list intializes to null + assert(E->getNumInits() == 0 && "Unexpected number of inits"); QualType Ty = E->getType()->getAs<ComplexType>()->getElementType(); llvm::Type* LTy = CGF.ConvertType(Ty); llvm::Value* zeroConstant = llvm::Constant::getNullValue(LTy); |