Author: rtrieu
Date: Wed Nov 14 21:43:50 2012
New Revision: 168023
URL: http://llvm.org/viewvc/llvm-project?rev=168023&view=rev
Log:
Fix an off-by-one error by switching < to <= in
-Wtautological-constant-out-of-range-compare and added test case.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/compare.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=168023&r1=168022&r2=168023&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Nov 14 21:43:50 2012
@@ -4385,7 +4385,7 @@
// Check to see if the constant is equivalent to a negative value
// cast to CommonT.
if (S.Context.getIntWidth(ConstantT) == S.Context.getIntWidth(CommonT) &&
- Value.isNegative() && Value.getMinSignedBits() < OtherWidth)
+ Value.isNegative() && Value.getMinSignedBits() <= OtherWidth)
return;
// The constant value rests between values that OtherT can represent
after
// conversion. Relational comparison still works, but equality
Modified: cfe/trunk/test/SemaCXX/compare.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/compare.cpp?rev=168023&r1=168022&r2=168023&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/compare.cpp (original)
+++ cfe/trunk/test/SemaCXX/compare.cpp Wed Nov 14 21:43:50 2012
@@ -311,6 +311,7 @@
(void)((int)other != (unsigned long)(0x00000000ffffffff)); //
expected-warning{{true}}
(void)((int)other != (unsigned long)(0x000000000fffffff));
(void)((int)other < (unsigned long)(0x00000000ffffffff)); //
expected-warning{{different signs}}
+ (void)((int)other == (unsigned)(0x800000000));
// Common unsigned, other unsigned, constant signed
(void)((unsigned long)other != (int)(0xffffffff)); //
expected-warning{{different signs}}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits