c: add the missing binary operatory when checking
for integer overflow. // rdar://13423975
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177162 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index be0480b..3926f01 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -5188,7 +5188,7 @@
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)
+ if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Mul && Opc != BO_Div)
return;
llvm::SmallVector<PartialDiagnosticAt, 4> Diags;
E->EvaluateForOverflow(Context, &Diags);
diff --git a/test/Sema/switch-1.c b/test/Sema/switch-1.c
index 82ce674..944048d 100644
--- a/test/Sema/switch-1.c
+++ b/test/Sema/switch-1.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
// rdar://11577384
+// rdar://13423975
int f(int i) {
switch (i) {
@@ -10,6 +11,8 @@
return 2;
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'}}
+ return 4;
case 2147483647:
return 0;
}