Fixed #7795 (ValueFlow: Value is not known after conditional increment )
This commit is contained in:
parent
5efb2e3be0
commit
bce0776417
|
@ -1317,6 +1317,13 @@ static bool valueFlowForward(Token * const startToken,
|
|||
bailout(tokenlist, errorLogger, tok2, "variable " + var->name() + " valueFlowForward, conditional return is assumed to be executed");
|
||||
return false;
|
||||
}
|
||||
} else if (indentlevel <= 0 &&
|
||||
Token::simpleMatch(tok2->link()->previous(), "else {") &&
|
||||
!isReturnScope(tok2->link()->tokAt(-2)) &&
|
||||
isVariableChanged(tok2->link(), tok2, varid, settings)) {
|
||||
std::list<ValueFlow::Value>::iterator it;
|
||||
for (it = values.begin(); it != values.end(); ++it)
|
||||
it->changeKnownToPossible();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2245,6 +2245,13 @@ private:
|
|||
ASSERT_EQUALS(9, value.intvalue);
|
||||
ASSERT(value.isPossible());
|
||||
|
||||
code = "void f(int c) {\n"
|
||||
" int x = 0;\n"
|
||||
" if (c) {} else { x++; }\n"
|
||||
" return x + 2;\n" // <- possible value
|
||||
"}";
|
||||
ASSERT(isNotKnownValues(code, "+"));
|
||||
|
||||
code = "void f() {\n"
|
||||
" int x = 0;\n"
|
||||
" fred.dostuff(x);\n"
|
||||
|
|
Loading…
Reference in New Issue