Fixed #6885 (valueflow ignores assignment of variable via function call)

This commit is contained in:
Daniel Marjamäki 2015-07-29 10:49:17 +02:00
parent 1f43550688
commit bf75ee9aed
2 changed files with 10 additions and 1 deletions

View File

@ -1381,8 +1381,10 @@ static bool valueFlowForward(Token * const startToken,
} }
if (inconclusive) { if (inconclusive) {
std::list<ValueFlow::Value>::iterator it; std::list<ValueFlow::Value>::iterator it;
for (it = values.begin(); it != values.end(); ++it) for (it = values.begin(); it != values.end(); ++it) {
it->inconclusive = true; it->inconclusive = true;
it->changeKnownToPossible();
}
} }
} }

View File

@ -1618,6 +1618,13 @@ private:
ASSERT_EQUALS(9, value.intvalue); ASSERT_EQUALS(9, value.intvalue);
ASSERT(value.isPossible()); ASSERT(value.isPossible());
code = "void f() {\n"
" int x = 0;\n"
" fred.dostuff(x);\n"
" if (x < 0) {}\n"
"}\n";
ASSERT(isNotKnownValues(code, "<"));
code = "void f() {\n" code = "void f() {\n"
" int x = 0;\n" " int x = 0;\n"
" if (y) { dostuff(x); }\n" " if (y) { dostuff(x); }\n"