summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-11-16 23:07:28 +0000
committerJohn McCall <rjmccall@apple.com>2010-11-16 23:07:28 +0000
commit83ce9d4a552987d34cbd500e983db8d770232379 (patch)
tree691cfdcff43a0b22aeeb2d08f0fa7922124f084b /lib/CodeGen/CGExpr.cpp
parentbee77f75358a5aaf2e2e01ab9cfd37ffc514ed7a (diff)
downloadclang-83ce9d4a552987d34cbd500e983db8d770232379.tar.gz
clang-83ce9d4a552987d34cbd500e983db8d770232379.tar.bz2
clang-83ce9d4a552987d34cbd500e983db8d770232379.tar.xz
Support compound complex operations as l-values in C++. Add a test
case based on CodeGen/volatile-1.c which tests the current C++ semantics, and note the many, many places we fall short of them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r--lib/CodeGen/CGExpr.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 0c24bf5d1a..6bfafca857 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1981,19 +1981,27 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
if (E->getOpcode() == BO_PtrMemD ||
E->getOpcode() == BO_PtrMemI)
return EmitPointerToDataMemberBinaryExpr(E);
-
- // Can only get l-value for binary operator expressions which are a
- // simple assignment of aggregate type.
- if (E->getOpcode() != BO_Assign)
- return EmitUnsupportedLValue(E, "binary l-value expression");
+ assert(E->isAssignmentOp() && "unexpected binary l-value");
+
if (!hasAggregateLLVMType(E->getType())) {
+ if (E->isCompoundAssignmentOp())
+ return EmitCompoundAssignOperatorLValue(cast<CompoundAssignOperator>(E));
+
+ assert(E->getOpcode() == BO_Assign && "unexpected binary l-value");
+
// Emit the LHS as an l-value.
LValue LV = EmitLValue(E->getLHS());
// Store the value through the l-value.
EmitStoreThroughLValue(EmitAnyExpr(E->getRHS()), LV, E->getType());
return LV;
}
+
+ if (E->getType()->isAnyComplexType())
+ return EmitComplexAssignmentLValue(E);
+
+ // The compound assignment operators are not used for aggregates.
+ assert(E->getOpcode() == BO_Assign && "aggregate compound assignment?");
return EmitAggExprToLValue(E);
}