Fix FP compareValueOutOfTypeRangeError (#4245)
* Fix FP compareValueOutOfTypeRangeError * Remove suppressions
This commit is contained in:
parent
27578e9c4c
commit
596f75e2af
|
@ -1803,6 +1803,8 @@ void CheckCondition::checkCompareValueOutOfTypeRange()
|
||||||
continue;
|
continue;
|
||||||
if (valueTok->getKnownIntValue() < 0 && valueTok->valueType() && valueTok->valueType()->sign != ValueType::Sign::SIGNED)
|
if (valueTok->getKnownIntValue() < 0 && valueTok->valueType() && valueTok->valueType()->sign != ValueType::Sign::SIGNED)
|
||||||
continue;
|
continue;
|
||||||
|
if (valueTok->valueType() && valueTok->valueType()->isTypeEqual(typeTok->valueType()))
|
||||||
|
continue;
|
||||||
int bits = 0;
|
int bits = 0;
|
||||||
switch (typeTok->valueType()->type) {
|
switch (typeTok->valueType()->type) {
|
||||||
case ValueType::Type::BOOL:
|
case ValueType::Type::BOOL:
|
||||||
|
|
|
@ -71,8 +71,8 @@ TEST(Test, warning_in_assert_macros)
|
||||||
ASSERT_GE(i, i);
|
ASSERT_GE(i, i);
|
||||||
|
|
||||||
unsigned int u = errno;
|
unsigned int u = errno;
|
||||||
// cppcheck-suppress [unsignedPositive, compareValueOutOfTypeRangeError]
|
// cppcheck-suppress [unsignedPositive]
|
||||||
ASSERT_GE(u, 0);
|
ASSERT_GE(u, 0);
|
||||||
// cppcheck-suppress [unsignedLessThanZero, compareValueOutOfTypeRangeError]
|
// cppcheck-suppress [unsignedLessThanZero]
|
||||||
ASSERT_LT(u, 0);
|
ASSERT_LT(u, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5258,6 +5258,12 @@ private:
|
||||||
"}", &settingsUnix64);
|
"}", &settingsUnix64);
|
||||||
ASSERT_EQUALS("", errout.str());
|
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"
|
check("void f() {\n"
|
||||||
" char c;\n"
|
" char c;\n"
|
||||||
" if ((c = foo()) != -1) {}\n"
|
" if ((c = foo()) != -1) {}\n"
|
||||||
|
|
Loading…
Reference in New Issue