Fix 10544: FP knownConditionTrueFalse with loop after check (#3508)

This commit is contained in:
Paul Fultz II 2021-10-14 09:47:15 -05:00 committed by GitHub
parent 6b9ef1fc58
commit f1f86db0da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -5384,7 +5384,6 @@ static void valueFlowInferCondition(TokenList* tokenlist,
ValueFlow::Value value = result.front();
value.intvalue = 1;
value.bound = ValueFlow::Value::Bound::Point;
value.setKnown();
setTokenValue(tok, value, settings);
} else if (Token::Match(tok, "%comp%|-") && tok->astOperand1() && tok->astOperand2()) {
std::vector<ValueFlow::Value> result =

View File

@ -4046,6 +4046,15 @@ private:
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Condition 'u1!=u2' is always true\n", errout.str());
// #10544
check("void f(int N) {\n"
" if (N > 0) {\n"
" while (N)\n"
" N = test();\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueContainer() {