Add support for binding references to scalar rvalues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72153 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index bb9f200..299bb6b 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -78,6 +78,14 @@
return RValue::get(LV.getAddress());
}
+ if (!hasAggregateLLVMType(E->getType())) {
+ // Make 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);
+ }
+
CGM.ErrorUnsupported(E, "reference binding");
return GetUndefRValue(DestType);
}