]> granicus.if.org Git - clang/commitdiff
Support va_arg on _Complex.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 10 Feb 2009 03:03:30 +0000 (03:03 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 10 Feb 2009 03:03:30 +0000 (03:03 +0000)
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
test/Coverage/c-language-features.inc

index 387635cb064a9d6eab6dd18ffca148f42572dac6..89a206dfb103b0b1c3aadd5e16f3931746848820 100644 (file)
@@ -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
 //===----------------------------------------------------------------------===//
index 8b56e6a55b69c3c729be147b87f4110b4b430fa4..6a475d6c2fd658f8a2a7d49f82aeedc01c500cc4 100644 (file)
@@ -103,6 +103,7 @@ void f4(int a0, int a1, int a2, va_list ap) {
   int t12_0 = __builtin_classify_type(t0);
   int t12_1 = __builtin_classify_type(t1);
   int t12_2 = __builtin_classify_type(t2);
+  // FIXME: Add _Complex and aggregate cases.
   int t13 = va_arg(ap, int);
   va_list t13_0;
   va_copy(t13_0, ap);