Fixed #7358 (valueflow: value is not known after conditional assignment)
This commit is contained in:
parent
477d02bbe7
commit
b5986f6ad2
|
@ -1158,9 +1158,14 @@ static bool valueFlowForward(Token * const startToken,
|
|||
errorLogger,
|
||||
settings);
|
||||
|
||||
if (isVariableChanged(startToken1, startToken1->link(), varid))
|
||||
if (isVariableChanged(startToken1, startToken1->link(), varid)) {
|
||||
removeValues(values, truevalues);
|
||||
|
||||
std::list<ValueFlow::Value>::iterator it;
|
||||
for (it = values.begin(); it != values.end(); ++it)
|
||||
it->changeKnownToPossible();
|
||||
}
|
||||
|
||||
// goto '}'
|
||||
tok2 = startToken1->link();
|
||||
|
||||
|
|
|
@ -1754,13 +1754,25 @@ private:
|
|||
ASSERT_EQUALS(3, value.intvalue);
|
||||
ASSERT(value.isKnown());
|
||||
|
||||
code = "void f() {\n"
|
||||
" int x = 15;\n"
|
||||
" if (x == 15) { x += 7; }\n" // <- condition is true
|
||||
"}";
|
||||
value = valueOfTok(code, "==");
|
||||
ASSERT_EQUALS(1, value.intvalue);
|
||||
ASSERT(value.isKnown());
|
||||
{
|
||||
code = "void f() {\n"
|
||||
" int x = 15;\n"
|
||||
" if (x == 15) { x += 7; }\n" // <- condition is true
|
||||
"}";
|
||||
value = valueOfTok(code, "==");
|
||||
ASSERT_EQUALS(1, value.intvalue);
|
||||
ASSERT(value.isKnown());
|
||||
|
||||
code = "int f() {\n"
|
||||
" int a = 0, x = 0;\n"
|
||||
" a = index();\n"
|
||||
" if (a != 0)\n"
|
||||
" x = next();\n"
|
||||
" return x + 1;\n"
|
||||
"}\n";
|
||||
value = valueOfTok(code, "+");
|
||||
ASSERT(value.isPossible());
|
||||
}
|
||||
|
||||
code = "void f() {\n"
|
||||
" int x;\n"
|
||||
|
|
Loading…
Reference in New Issue