valueFlowAfterCondition: wrong analysis for floats

This commit is contained in:
Daniel Marjamäki 2014-06-25 06:17:44 +02:00
parent ac4e727da7
commit c77786a745
2 changed files with 8 additions and 2 deletions

View File

@ -787,9 +787,8 @@ static void valueFlowAfterCondition(TokenList *tokenlist, ErrorLogger *errorLogg
vartok = tok->astOperand2();
numtok = tok->astOperand1();
}
if (!vartok->isName() || !numtok->isNumber())
if (!vartok->isName() || !numtok->isNumber() || !MathLib::isInt(numtok->str()))
continue;
} else if (tok->str() == "!") {
vartok = tok->astOperand1();
numtok = nullptr;

View File

@ -790,6 +790,13 @@ private:
" x);\n"
"}";
ASSERT_EQUALS(true, testValueOfX(code, 3U, 4));
// TODO: float
code = "void f(float x) {\n"
" if (x == 0.5) {}\n"
" a = x;\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
}
void valueFlowBitAnd() {