[cfe-commits] r84518 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/references.cpp
Anders Carlsson
andersca at mac.com
Mon Oct 19 11:28:22 PDT 2009
Author: andersca
Date: Mon Oct 19 13:28:22 2009
New Revision: 84518
URL: http://llvm.org/viewvc/llvm-project?rev=84518&view=rev
Log:
Handle emitting the assignment operator when the lhs is a reference. Fixes PR5227.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/references.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=84518&r1=84517&r2=84518&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 19 13:28:22 2009
@@ -1367,6 +1367,16 @@
if (E->getOpcode() != BinaryOperator::Assign)
return EmitUnsupportedLValue(E, "binary l-value expression");
+ if (!hasAggregateLLVMType(E->getType())) {
+ // Emit the LHS as an l-value.
+ LValue LV = EmitLValue(E->getLHS());
+
+ llvm::Value *RHS = EmitScalarExpr(E->getRHS());
+ EmitStoreOfScalar(RHS, LV.getAddress(), LV.isVolatileQualified(),
+ E->getType());
+ return LV;
+ }
+
llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType()));
EmitAggExpr(E, Temp, false);
// FIXME: Are these qualifiers correct?
Modified: cfe/trunk/test/CodeGenCXX/references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/references.cpp?rev=84518&r1=84517&r2=84518&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/references.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/references.cpp Mon Oct 19 13:28:22 2009
@@ -130,3 +130,9 @@
}
}
+// PR5227.
+namespace PR5227 {
+void f(int &a) {
+ (a = 10) = 20;
+}
+}
More information about the cfe-commits
mailing list