<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 15, 2013, at 10:14 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">On Fri, Mar 15, 2013 at 10:11 AM, jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:<br><blockquote type="cite"><br>On Mar 15, 2013, at 10:10 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br><br>On Fri, Mar 15, 2013 at 9:36 AM, Fariborz Jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>><br>wrote:<br><br>Author: fjahanian<br>Date: Fri Mar 15 11:36:04 2013<br>New Revision: 177162<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=177162&view=rev">http://llvm.org/viewvc/llvm-project?rev=177162&view=rev</a><br>Log:<br>c: add the missing binary operatory when checking<br>for integer overflow. // <a href="rdar://13423975">rdar://13423975</a><br><br>Modified:<br>  cfe/trunk/lib/Sema/SemaChecking.cpp<br>  cfe/trunk/test/Sema/switch-1.c<br><br>Modified: cfe/trunk/lib/Sema/SemaChecking.cpp<br>URL:<br><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=177162&r1=177161&r2=177162&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=177162&r1=177161&r2=177162&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)<br>+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 15 11:36:04 2013<br>@@ -5188,7 +5188,7 @@ void Sema::CheckImplicitConversions(Expr<br>void Sema::CheckForIntOverflow (Expr *E) {<br> if (const BinaryOperator *BExpr =<br>dyn_cast<BinaryOperator>(E->IgnoreParens())) {<br>   unsigned Opc = BExpr->getOpcode();<br>-    if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Mul)<br>+    if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Mul && Opc != BO_Div)<br>     return;<br>   llvm::SmallVector<PartialDiagnosticAt, 4> Diags;<br>   E->EvaluateForOverflow(Context, &Diags);<br><br>Modified: cfe/trunk/test/Sema/switch-1.c<br>URL:<br>http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch-1.c?rev=177162&r1=177161&r2=177162&view=diff<br>==============================================================================<br>--- cfe/trunk/test/Sema/switch-1.c (original)<br>+++ cfe/trunk/test/Sema/switch-1.c Fri Mar 15 11:36:04 2013<br>@@ -1,6 +1,7 @@<br>// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 %s<br>// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple<br>x86_64-apple-darwin10 %s<br>// rdar://11577384<br>+// rdar://13423975<br><br>int f(int i) {<br> switch (i) {<br>@@ -10,6 +11,8 @@ int f(int i) {<br>     return 2;<br>   case (123456 *789012) + 1:  // expected-warning {{overflow in<br>expression; result is -1375982336 with type 'int'}}<br>     return 3;<br>+    case (2147483647*4)/4:     // expected-warning {{overflow in<br>expression; result is -4 with type 'int'}}<br><br><br>Yeah, I'm with Jordan here - why are we warning about the division.<br>Division can't cause overflow. Shouldn't we be warning about that<br>multiplication?<br><br><br>We are warning about multiplication.<br></blockquote><br>Then why are we selecting which binary operators to "see" through?<br>Which expression would we not want to see through to perform this<br>warning?</div></blockquote><br></div><div>Come to think of it. There is no reason for it. Patch is coming.</div><div>- Fariborz</div><div><br></div><br></body></html>