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();
|
return tok->variable()->isFloatingType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cast
|
||||||
|
if (Token::Match(tok, "( const| float|double )"))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (tok->isOp())
|
if (tok->isOp())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ public:
|
||||||
checkOther.checkCommaSeparatedReturn();
|
checkOther.checkCommaSeparatedReturn();
|
||||||
checkOther.checkIgnoredReturnValue();
|
checkOther.checkIgnoredReturnValue();
|
||||||
checkOther.checkRedundantPointerOp();
|
checkOther.checkRedundantPointerOp();
|
||||||
|
checkOther.checkZeroDivision();
|
||||||
|
|
||||||
// --check-library : functions with nonmatching configuration
|
// --check-library : functions with nonmatching configuration
|
||||||
checkOther.checkLibraryMatchFunctions();
|
checkOther.checkLibraryMatchFunctions();
|
||||||
|
@ -96,7 +97,6 @@ public:
|
||||||
checkOther.checkCastIntToCharAndBack();
|
checkOther.checkCastIntToCharAndBack();
|
||||||
|
|
||||||
checkOther.invalidFunctionUsage();
|
checkOther.invalidFunctionUsage();
|
||||||
checkOther.checkZeroDivision();
|
|
||||||
checkOther.checkMathFunctions();
|
checkOther.checkMathFunctions();
|
||||||
|
|
||||||
checkOther.checkMisusedScopedObject();
|
checkOther.checkMisusedScopedObject();
|
||||||
|
|
|
@ -266,6 +266,16 @@ private:
|
||||||
" cout << 1. / 0;\n"
|
" cout << 1. / 0;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void zeroDiv2() {
|
||||||
|
|
Loading…
Reference in New Issue