aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-10-25 22:19:13 +0000
committerDevang Patel <dpatel@apple.com>2007-10-25 22:19:13 +0000
commitf86206ffbfd84a724f871409d09b31401e3f0d40 (patch)
treedd9cc7c127cde2ca2b197a655d6010edb1a8972d
parent5825ac2950db54ea5ce8a4f3f87fae569eeefe65 (diff)
Fix "strbuf += stufflen;" crash.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43365 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--CodeGen/CGExprScalar.cpp6
-rw-r--r--test/CodeGen/compound.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp
index 0d86ccc022..9bfd82ec0a 100644
--- a/CodeGen/CGExprScalar.cpp
+++ b/CodeGen/CGExprScalar.cpp
@@ -618,8 +618,10 @@ Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E,
// Convert the LHS/RHS values to the computation type.
OpInfo.LHS = EmitScalarConversion(OpInfo.LHS, LHSTy, ComputeType);
- // Do not merge types for -= where the LHS is a pointer.
- if (E->getOpcode() != BinaryOperator::SubAssign ||
+ // Do not merge types for -= or += where the LHS is a pointer.
+ if (!(E->getOpcode() == BinaryOperator::SubAssign ||
+ E->getOpcode() == BinaryOperator::AddAssign) ||
+ // if (E->getOpcode() != BinaryOperator::SubAssign ||
!E->getLHS()->getType()->isPointerType()) {
OpInfo.RHS = EmitScalarConversion(OpInfo.RHS, RHSTy, ComputeType);
}
diff --git a/test/CodeGen/compound.c b/test/CodeGen/compound.c
index 778a5ce968..0909565631 100644
--- a/test/CodeGen/compound.c
+++ b/test/CodeGen/compound.c
@@ -14,3 +14,7 @@ void test1() {
short x;
void test2(char c) { x += c; }
+void foo(char *strbuf) {
+ int stufflen = 4;
+ strbuf += stufflen;
+}