[cfe-commits] r43365 - in /cfe/trunk: CodeGen/CGExprScalar.cpp test/CodeGen/compound.c

Devang Patel dpatel at apple.com
Thu Oct 25 15:19:13 PDT 2007


Author: dpatel
Date: Thu Oct 25 17:19:13 2007
New Revision: 43365

URL: http://llvm.org/viewvc/llvm-project?rev=43365&view=rev
Log:
Fix  "strbuf += stufflen;" crash.


Modified:
    cfe/trunk/CodeGen/CGExprScalar.cpp
    cfe/trunk/test/CodeGen/compound.c

Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=43365&r1=43364&r2=43365&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Thu Oct 25 17:19:13 2007
@@ -618,8 +618,10 @@
   // 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);
   }

Modified: cfe/trunk/test/CodeGen/compound.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/compound.c?rev=43365&r1=43364&r2=43365&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/compound.c (original)
+++ cfe/trunk/test/CodeGen/compound.c Thu Oct 25 17:19:13 2007
@@ -14,3 +14,7 @@
 short x; 
 void test2(char c) { x += c; }
 
+void foo(char *strbuf) {
+  int stufflen = 4;
+  strbuf += stufflen;
+}





More information about the cfe-commits mailing list