Fix 10548: FP knownConditionTrueFalse with loop and operator++ (#3511)

This commit is contained in:
Paul Fultz II 2021-10-15 03:59:01 -05:00 committed by GitHub
parent 89515600e4
commit 7f04658585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -417,7 +417,8 @@ struct ForwardTraversal {
actions |= allAnalysis;
// do while(false) is not really a loop
if (checkElse && isDoWhile &&
(condTok->hasKnownIntValue() || (!bodyAnalysis.isModified() && condAnalysis.isRead()))) {
(condTok->hasKnownIntValue() ||
(!bodyAnalysis.isModified() && !condAnalysis.isModified() && condAnalysis.isRead()))) {
if (updateRange(endBlock->link(), endBlock) == Progress::Break)
return Break();
return updateRecursive(condTok);

View File

@ -3793,6 +3793,13 @@ private:
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #10548
check("void f() {\n"
" int i = 0;\n"
" do {} while (i++ == 0);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueSymbolic()