void Sema::CheckForIntOverflow (Expr *E) {
if (const BinaryOperator *BExpr = dyn_cast<BinaryOperator>(E->IgnoreParens())) {
unsigned Opc = BExpr->getOpcode();
- if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Mul && Opc != BO_Div)
- return;
+ switch (Opc) {
+ case BO_Add:
+ case BO_Sub:
+ case BO_Mul:
+ case BO_Div:
+ case BO_Rem:
+ break;
+ default:
+ return;
+ }
llvm::SmallVector<PartialDiagnosticAt, 4> Diags;
E->EvaluateForOverflow(Context, &Diags);
}
case (123456 *789012) + 1: // expected-warning {{overflow in expression; result is -1375982336 with type 'int'}}
return 3;
case (2147483647*4)/4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
+ case (2147483647*4)%4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
return 4;
case 2147483647:
return 0;