summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-20 01:35:03 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-20 01:35:03 +0000
commit02bb7f0ac89b873d32aa1f6cdd9e26be0fcb1014 (patch)
tree8cae5c622c6582795b17889578774c63fd19d7c5
parent387f863ddefd354a0a523c65ba15c5be7e4fcbca (diff)
downloadbcm5719-llvm-02bb7f0ac89b873d32aa1f6cdd9e26be0fcb1014.tar.gz
bcm5719-llvm-02bb7f0ac89b873d32aa1f6cdd9e26be0fcb1014.zip
irgen for references to complex rvales (Very important...)
llvm-svn: 72157
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp8
-rw-r--r--clang/test/CodeGenCXX/references.cpp2
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index eaf0873610d..0886ad040a4 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -79,11 +79,17 @@ RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
}
if (!hasAggregateLLVMType(E->getType())) {
- // Make a temporary variable that we can bind the reference to.
+ // Create a temporary variable that we can bind the reference to.
llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(E->getType()),
"reftmp");
EmitStoreOfScalar(EmitScalarExpr(E), Temp, false, E->getType());
return RValue::get(Temp);
+ } else if (E->getType()->isAnyComplexType()) {
+ // Create a temporary variable that we can bind the reference to.
+ llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(E->getType()),
+ "reftmp");
+ EmitComplexExprIntoAddr(E, Temp, false);
+ return RValue::get(Temp);
}
CGM.ErrorUnsupported(E, "reference binding");
diff --git a/clang/test/CodeGenCXX/references.cpp b/clang/test/CodeGenCXX/references.cpp
index afcaaf2d7c1..9b9e0f8623b 100644
--- a/clang/test/CodeGenCXX/references.cpp
+++ b/clang/test/CodeGenCXX/references.cpp
@@ -44,6 +44,8 @@ void test_scalar() {
void test_complex() {
_Complex int a = 10i;
f(a);
+
+ f(10i);
}
void test_aggregate() {
OpenPOWER on IntegriCloud