Fixed #5861 (valueFlowSubFunction: fp for float value)
This commit is contained in:
parent
46479ced7e
commit
9eaadc81e2
|
@ -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 {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue