<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:10 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 9:36 AM, Fariborz Jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:<br><blockquote type="cite">Author: fjahanian<br>Date: Fri Mar 15 11:36:04 2013<br>New Revision: 177162<br><br>URL:<span class="Apple-converted-space"> </span><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. //<span class="Apple-converted-space"> </span><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:<span class="Apple-converted-space"> </span><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 = 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:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch-1.c?rev=177162&r1=177161&r2=177162&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch-1.c?rev=177162&r1=177161&r2=177162&view=diff</a><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 x86_64-apple-darwin10 %s<br>//<span class="Apple-converted-space"> </span><a href="rdar://11577384">rdar://11577384</a><br>+//<span class="Apple-converted-space"> </span><a href="rdar://13423975">rdar://13423975</a><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 expression; result is -1375982336 with type 'int'}}<br>      return 3;<br>+    case (2147483647*4)/4:     // expected-warning {{overflow in expression; result is -4 with type 'int'}}<br></blockquote><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></div></blockquote><div><br></div>We are warning about multiplication.</div><div>- Fariborz</div><div><br><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;"><br><blockquote type="cite">+      return 4;<br>    case 2147483647:<br>      return 0;<br>  }<br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></blockquote></div></blockquote></div><br></body></html>