summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-10-19 18:28:22 +0000
committerAnders Carlsson <andersca@mac.com>2009-10-19 18:28:22 +0000
commit0999aafda58ecd37709199dc6c4430ba53e7ae6a (patch)
treef34ed0c6b2ed37053821b764b732fb8deb0b9a36
parent0ed889521be2f4ca459d08ef8b8b6a0711412e07 (diff)
downloadbcm5719-llvm-0999aafda58ecd37709199dc6c4430ba53e7ae6a.tar.gz
bcm5719-llvm-0999aafda58ecd37709199dc6c4430ba53e7ae6a.zip
Handle emitting the assignment operator when the lhs is a reference. Fixes PR5227.
llvm-svn: 84518
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp10
-rw-r--r--clang/test/CodeGenCXX/references.cpp6
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6542aa50d26..29ca900ed31 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1367,6 +1367,16 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
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?
diff --git a/clang/test/CodeGenCXX/references.cpp b/clang/test/CodeGenCXX/references.cpp
index 682aab310d0..8e0e1cbe84e 100644
--- a/clang/test/CodeGenCXX/references.cpp
+++ b/clang/test/CodeGenCXX/references.cpp
@@ -130,3 +130,9 @@ namespace T {
}
}
+// PR5227.
+namespace PR5227 {
+void f(int &a) {
+ (a = 10) = 20;
+}
+}
OpenPOWER on IntegriCloud