diff options
-rw-r--r-- | CodeGen/CGExprScalar.cpp | 6 | ||||
-rw-r--r-- | 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; +} |