Fixed #3472 (false positive: (error) Passing value 0 to log() leads to undefined result)
This commit is contained in:
parent
ee55d3294a
commit
65ce55e675
|
@ -2160,7 +2160,14 @@ void CheckOther::zerodivError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkMathFunctions()
|
||||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
const SymbolDatabase *db = _tokenizer->getSymbolDatabase();
|
||||
|
||||
std::list<Scope>::const_iterator scope;
|
||||
for (scope = db->scopeList.begin(); scope != db->scopeList.end(); ++scope) {
|
||||
if (scope->type != Scope::eFunction)
|
||||
continue;
|
||||
|
||||
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
||||
if (tok->varId() == 0 && Token::Match(tok, "log|log10 ( %num% )")) {
|
||||
bool isNegative = MathLib::isNegative(tok->strAt(2));
|
||||
bool isInt = MathLib::isInt(tok->strAt(2));
|
||||
|
@ -2209,6 +2216,7 @@ void CheckOther::checkMathFunctions()
|
|||
mathfunctionCallError(tok, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckOther::mathfunctionCallError(const Token *tok, const unsigned int numParam)
|
||||
|
|
|
@ -929,6 +929,9 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #3473 - no warning if "log" is a variable
|
||||
check("Fred::Fred() : log(0) { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// acos
|
||||
check("void foo()\n"
|
||||
|
|
Loading…
Reference in New Issue