From 4e484b8134c7eaeced03be7e4e0f7349def9b355 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 10 Feb 2009 03:03:30 +0000 Subject: Support va_arg on _Complex. gcc compat test suite results (Darwin x86-32 & -64): -- # of expected passes 1110 # of unexpected failures 74 # of unresolved testcases 168 # of unsupported tests 2 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64197 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprComplex.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/CodeGen/CGExprComplex.cpp') diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 387635cb06..89a206dfb1 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -192,6 +192,8 @@ public: ComplexPairTy VisitChooseExpr(ChooseExpr *CE); ComplexPairTy VisitInitListExpr(InitListExpr *E); + + ComplexPairTy VisitVAArgExpr(VAArgExpr *E); }; } // end anonymous namespace. @@ -528,6 +530,22 @@ ComplexPairTy ComplexExprEmitter::VisitInitListExpr(InitListExpr *E) { return ComplexPairTy(zeroConstant, zeroConstant); } +ComplexPairTy ComplexExprEmitter::VisitVAArgExpr(VAArgExpr *E) { + llvm::Value *ArgValue = CGF.EmitLValue(E->getSubExpr()).getAddress(); + llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, E->getType()); + + if (!ArgPtr) { + CGF.ErrorUnsupported(E, "complex va_arg expression"); + const llvm::Type *EltTy = + CGF.ConvertType(E->getType()->getAsComplexType()->getElementType()); + llvm::Value *U = llvm::UndefValue::get(EltTy); + return ComplexPairTy(U, U); + } + + // FIXME Volatility. + return EmitLoadOfComplex(ArgPtr, false); +} + //===----------------------------------------------------------------------===// // Entry Point into this File //===----------------------------------------------------------------------===// -- cgit v1.2.3