From f86206ffbfd84a724f871409d09b31401e3f0d40 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 25 Oct 2007 22:19:13 +0000 Subject: [PATCH] Fix "strbuf += stufflen;" crash. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43365 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGExprScalar.cpp | 6 ++++-- test/CodeGen/compound.c | 4 ++++ 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; +} -- 2.50.1