Fix issue 8253: False negative: Comparison is always true (early return) (#3043)
This commit is contained in:
parent
1858465bca
commit
b469da1069
|
@ -386,8 +386,6 @@ struct ForwardTraversal {
|
|||
Token* endBlock = endCond->next()->link();
|
||||
Token* condTok = getCondTok(tok);
|
||||
Token* initTok = getInitTok(tok);
|
||||
if (!condTok)
|
||||
return Progress::Break;
|
||||
if (initTok && updateRecursive(initTok) == Progress::Break)
|
||||
return Progress::Break;
|
||||
if (Token::Match(tok, "for|while (")) {
|
||||
|
|
|
@ -4270,6 +4270,16 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 10U, 0));
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 10U, 1));
|
||||
|
||||
code = "void f() {\n"
|
||||
" const int size = arrayInfo.num(0);\n"
|
||||
" if (size <= 0)\n"
|
||||
" return;\n"
|
||||
" for (;;)\n"
|
||||
" if (size > 0) {}\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(true, valueOfTok(code, "> 0").isKnown());
|
||||
ASSERT_EQUALS(true, valueOfTok(code, "> 0").intvalue == 1);
|
||||
}
|
||||
|
||||
static std::string isPossibleContainerSizeValue(const std::list<ValueFlow::Value> &values, MathLib::bigint i) {
|
||||
|
|
Loading…
Reference in New Issue