FwdAnalysis: fix FP in loop
This commit is contained in:
parent
152df1bf00
commit
46a0172480
|
@ -1104,20 +1104,12 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const
|
|||
conditionEnd = conditionStart->link();
|
||||
}
|
||||
if (conditionStart && conditionEnd) {
|
||||
bool write = false;
|
||||
bool used = false;
|
||||
for (const Token *condTok = conditionStart; condTok != conditionEnd; condTok = condTok->next()) {
|
||||
if (Token::Match(condTok, "=|++|--")) {
|
||||
visitAstNodes(condTok->astOperand1(),
|
||||
[&](const Token *writeTok) {
|
||||
if (exprVarIds.find(writeTok->varId()) != exprVarIds.end())
|
||||
write = true;
|
||||
return write ? ChildrenToVisit::done : ChildrenToVisit::op1_and_op2;
|
||||
});
|
||||
if (write)
|
||||
break;
|
||||
}
|
||||
if (exprVarIds.find(condTok->varId()) != exprVarIds.end())
|
||||
used = true;
|
||||
}
|
||||
if (write)
|
||||
if (used)
|
||||
return Result(Result::Type::BAILOUT);
|
||||
}
|
||||
|
||||
|
|
|
@ -2153,6 +2153,14 @@ private:
|
|||
" while (x < 10) { x = x + 1; }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("void fun()\n"
|
||||
"{\n"
|
||||
" int status = 0;\n"
|
||||
" for (ind = 0; ((ind < nrArgs) && (status < 10)); ind++)\n"
|
||||
" status = x;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1() {
|
||||
|
|
Loading…
Reference in New Issue