summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CGCall.cpp5
-rw-r--r--clang/test/CodeGen/complex.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 1fc4143d60a..220586db589 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -868,7 +868,10 @@ RValue CodeGenFunction::EmitCall(llvm::Value *Callee,
llvm::PointerType::getUnqual(RetAI.getCoerceToType());
llvm::Value *V = CreateTempAlloca(ConvertType(RetTy), "tmp");
Builder.CreateStore(CI, Builder.CreateBitCast(V, CoerceToPTy));
- return RValue::getAggregate(V);
+ if (RetTy->isAnyComplexType())
+ return RValue::getComplex(LoadComplexFromAddr(V, false));
+ else
+ return RValue::getAggregate(V);
}
case ABIArgInfo::ByVal:
diff --git a/clang/test/CodeGen/complex.c b/clang/test/CodeGen/complex.c
index 93e25cf459c..9c0e3d5fc5f 100644
--- a/clang/test/CodeGen/complex.c
+++ b/clang/test/CodeGen/complex.c
@@ -51,3 +51,10 @@ void t3() {
__complex__ long long v = 2;
}
+// PR3131
+float _Complex t4();
+
+void t5() {
+ float _Complex x = t4();
+}
+
OpenPOWER on IntegriCloud