Fixed #6598 (False positive zerodivcond - cast to double ignored)
This commit is contained in:
parent
7cdeb70efa
commit
389aec51ae
|
@ -53,6 +53,10 @@ bool astIsFloat(const Token *tok, bool unknown)
|
|||
return tok->variable()->isFloatingType();
|
||||
}
|
||||
|
||||
// cast
|
||||
if (Token::Match(tok, "( const| float|double )"))
|
||||
return true;
|
||||
|
||||
if (tok->isOp())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ public:
|
|||
checkOther.checkCommaSeparatedReturn();
|
||||
checkOther.checkIgnoredReturnValue();
|
||||
checkOther.checkRedundantPointerOp();
|
||||
checkOther.checkZeroDivision();
|
||||
|
||||
// --check-library : functions with nonmatching configuration
|
||||
checkOther.checkLibraryMatchFunctions();
|
||||
|
@ -96,7 +97,6 @@ public:
|
|||
checkOther.checkCastIntToCharAndBack();
|
||||
|
||||
checkOther.invalidFunctionUsage();
|
||||
checkOther.checkZeroDivision();
|
||||
checkOther.checkMathFunctions();
|
||||
|
||||
checkOther.checkMisusedScopedObject();
|
||||
|
|
|
@ -266,6 +266,16 @@ private:
|
|||
" cout << 1. / 0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo() {\n"
|
||||
" cout << 42 / (double)0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo() {\n"
|
||||
" cout << 42 / (float)0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void zeroDiv2() {
|
||||
|
|
Loading…
Reference in New Issue