]> granicus.if.org Git - clang/commitdiff
Fix "strbuf += stufflen;" crash.
authorDevang Patel <dpatel@apple.com>
Thu, 25 Oct 2007 22:19:13 +0000 (22:19 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 25 Oct 2007 22:19:13 +0000 (22:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43365 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGExprScalar.cpp
test/CodeGen/compound.c

index 0d86ccc02245b25db78f103b85de7bc015ff1414..9bfd82ec0a0905d2aa9373e556c5d55ee6c3a0f2 100644 (file)
@@ -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);
   }
index 778a5ce96817d25f267fbe7317b8cda3a34adc5a..09095656316293a4114f68279374eea844a4c67d 100644 (file)
@@ -14,3 +14,7 @@ void test1() {
 short x; 
 void test2(char c) { x += c; }
 
+void foo(char *strbuf) {
+  int stufflen = 4;
+  strbuf += stufflen;
+}