Fixed #9816 (False positive: Condition '!b' is always false in nested do-while loop)
This commit is contained in:
parent
aa066755be
commit
46e008c3e2
|
@ -313,6 +313,10 @@ struct ForwardTraversal {
|
|||
return Progress::Break;
|
||||
} else if (scope->type == Scope::eLambda) {
|
||||
return Progress::Break;
|
||||
} else if (scope->type == Scope::eDo && Token::simpleMatch(tok, "} while (")) {
|
||||
if (updateLoop(tok, tok->tokAt(2)->astOperand2()) == Progress::Break)
|
||||
return Progress::Break;
|
||||
tok = tok->linkAt(2);
|
||||
} else if (Token::simpleMatch(tok->next(), "else {")) {
|
||||
tok = tok->linkAt(2);
|
||||
}
|
||||
|
|
|
@ -3409,6 +3409,20 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #9816
|
||||
check("bool g();\n"
|
||||
"void f() {\n"
|
||||
" bool b = false;\n"
|
||||
" do {\n"
|
||||
" do {\n"
|
||||
" if (g())\n"
|
||||
" break;\n"
|
||||
" b = true;\n"
|
||||
" } while(false);\n"
|
||||
" } while(!b);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void alwaysTrueInfer() {
|
||||
|
|
Loading…
Reference in New Issue