Fix an off-by-one error by switching < to <= in -Wtautological-constant-out-of-range-compare and added test case.
llvm-svn: 168023
This commit is contained in:
@@ -4385,7 +4385,7 @@ static void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E,
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user