Fixed #9062 (False positive "condition is always true")
This commit is contained in:
parent
e11dcc609b
commit
bbcffce529
|
@ -1512,7 +1512,7 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const
|
|||
if (Token::simpleMatch(tok, "asm ("))
|
||||
return Result(Result::Type::BAILOUT);
|
||||
|
||||
if (mWhat == What::ValueFlow && Token::Match(tok, "while|for (")) {
|
||||
if (mWhat == What::ValueFlow && (Token::Match(tok, "while|for (") || Token::simpleMatch(tok, "do {"))) {
|
||||
// TODO: only bailout if expr is reassigned in loop
|
||||
return Result(Result::Type::BAILOUT);
|
||||
}
|
||||
|
|
|
@ -2585,6 +2585,16 @@ private:
|
|||
values = tokenValues(code, ">");
|
||||
ASSERT_EQUALS(true, values.empty());
|
||||
|
||||
code = "void foo() {\n"
|
||||
" struct ISO_PVD_s pvd;\n"
|
||||
" pvd.descr_type = 0xff;\n"
|
||||
" do {\n"
|
||||
" if (pvd.descr_type == 0xff) {}\n"
|
||||
" dostuff(&pvd);\n"
|
||||
" } while (condition)\n"
|
||||
"}";
|
||||
values = tokenValues(code, "==");
|
||||
ASSERT_EQUALS(true, values.empty());
|
||||
}
|
||||
|
||||
void valueFlowSwitchVariable() {
|
||||
|
|
Loading…
Reference in New Issue