Fix "strbuf += stufflen;" crash.

llvm-svn: 43365
This commit is contained in:
Devang Patel 2007-10-25 22:19:13 +00:00
parent 65e804a9c3
commit b989c9e65c
2 changed files with 8 additions and 2 deletions

View 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);
}

View File

@ -14,3 +14,7 @@ void test1() {
short x;
void test2(char c) { x += c; }
void foo(char *strbuf) {
int stufflen = 4;
strbuf += stufflen;
}