Patch to warn on interger overflow in presence of

implicit casts. Reviewed by Reid Kleckner.
rdar://18405357

llvm-svn: 219712
This commit is contained in:
Fariborz Jahanian 2014-10-14 20:27:05 +00:00
parent b8e9b8b703
commit c694e693b0
2 changed files with 7 additions and 2 deletions

View File

@ -6754,8 +6754,8 @@ void Sema::CheckImplicitConversions(Expr *E, SourceLocation CC) {
/// Diagnose when expression is an integer constant expression and its evaluation
/// results in integer overflow
void Sema::CheckForIntOverflow (Expr *E) {
if (isa<BinaryOperator>(E->IgnoreParens()))
E->EvaluateForOverflow(Context);
if (isa<BinaryOperator>(E->IgnoreParenCasts()))
E->IgnoreParenCasts()->EvaluateForOverflow(Context);
}
namespace {

View File

@ -20,3 +20,8 @@ int f(int i) {
return (i, 65537) * 65537; // expected-warning {{overflow in expression; result is 131073 with type 'int'}} \
// expected-warning {{expression result unused}}
}
// rdar://18405357
unsigned long long l = 65536 * 65536; // expected-warning {{overflow in expression; result is 0 with type 'int'}}
unsigned long long l2 = 65536 * (unsigned)65536;
unsigned long long l3 = 65536 * 65536ULL;