Bind references to lvalues correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72150 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index dc44798..bb9f200 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -72,6 +72,12 @@
RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
QualType DestType) {
+ if (E->isLvalue(getContext()) == Expr::LV_Valid) {
+ // Emit the expr as an lvalue.
+ LValue LV = EmitLValue(E);
+ return RValue::get(LV.getAddress());
+ }
+
CGM.ErrorUnsupported(E, "reference binding");
return GetUndefRValue(DestType);
}