#ticket 1513 added fmod() support

This commit is contained in:
Martin Ettl 2010-04-05 19:45:33 +02:00
parent d4923e2a92
commit 218c18496d
2 changed files with 13 additions and 0 deletions

View File

@ -2570,6 +2570,13 @@ void CheckOther::checkMathFunctions()
{
mathfunctionCallError(tok,2);
}
// fmod ( x , y) If y is zero, then either a range error will occur or the function will return zero (implementation-defined).
else if (Token::Match(tok, "fmod ( %num% , %num% )") &&
MathLib::isNullValue(tok->tokAt(4)->str()))
{
mathfunctionCallError(tok,2);
}
}
}

View File

@ -2306,6 +2306,12 @@ private:
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Passing value 0 and 0 to atan2() leads to undefined result\n", errout.str());
check("void foo()\n"
"{\n"
" std::cout << fmod(1.0,0) << std::endl;\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Passing value 1.0 and 0 to fmod() leads to undefined result\n", errout.str());
}
};