Fix FP compareValueOutOfTypeRangeError (#4245)

* Fix FP compareValueOutOfTypeRangeError

* Remove suppressions
This commit is contained in:
chrchr-github 2022-07-01 10:48:32 +02:00 committed by GitHub
parent 27578e9c4c
commit 596f75e2af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -1803,6 +1803,8 @@ void CheckCondition::checkCompareValueOutOfTypeRange()
continue;
if (valueTok->getKnownIntValue() < 0 && valueTok->valueType() && valueTok->valueType()->sign != ValueType::Sign::SIGNED)
continue;
if (valueTok->valueType() && valueTok->valueType()->isTypeEqual(typeTok->valueType()))
continue;
int bits = 0;
switch (typeTok->valueType()->type) {
case ValueType::Type::BOOL:

View File

@ -71,8 +71,8 @@ TEST(Test, warning_in_assert_macros)
ASSERT_GE(i, i);
unsigned int u = errno;
// cppcheck-suppress [unsignedPositive, compareValueOutOfTypeRangeError]
// cppcheck-suppress [unsignedPositive]
ASSERT_GE(u, 0);
// cppcheck-suppress [unsignedLessThanZero, compareValueOutOfTypeRangeError]
// cppcheck-suppress [unsignedLessThanZero]
ASSERT_LT(u, 0);
}

View File

@ -5258,6 +5258,12 @@ private:
"}", &settingsUnix64);
ASSERT_EQUALS("", errout.str());
check("int f(int x) {\n"
" const int i = 0xFFFFFFFF;\n"
" if (x == i) {}\n"
"}", &settingsUnix64);
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" char c;\n"
" if ((c = foo()) != -1) {}\n"