Fixed #5861 (valueFlowSubFunction: fp for float value)

This commit is contained in:
Daniel Marjamäki 2014-06-28 12:04:20 +02:00
parent 46479ced7e
commit 9eaadc81e2
2 changed files with 8 additions and 1 deletions

View File

@ -1203,7 +1203,7 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger,
// passing value(s) to function
if (Token::Match(tok, "[(,] %var% [,)]") && !tok->next()->values.empty())
argvalues = tok->next()->values;
else if (Token::Match(tok, "[(,] %num% [,)]")) {
else if (Token::Match(tok, "[(,] %num% [,)]") && MathLib::isInt(tok->strAt(1))) {
argvalues.clear();
argvalues.push_back(ValueFlow::Value(MathLib::toLongNumber(tok->next()->str())));
} else {

View File

@ -918,6 +918,13 @@ private:
"void f2() { f1(0); }";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 0));
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
// #5861 - fp with float
code = "void f1(float x) {\n"
" return 1.0 / x;\n"
"}\n"
"void f2() { f1(0.5); }";
ASSERT_EQUALS(false, testValueOfX(code, 2U, 0));
}
};