Fixed #9036 (false positive: (style) Condition 's.x<127U' is always true)
This commit is contained in:
parent
bd83630f2e
commit
33ec78fe6e
|
@ -5779,6 +5779,8 @@ static void valueFlowContainerAfterCondition(TokenList *tokenlist,
|
|||
static void valueFlowFwdAnalysis(const TokenList *tokenlist, const Settings *settings)
|
||||
{
|
||||
for (const Token *tok = tokenlist->front(); tok; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "for ("))
|
||||
tok = tok->linkAt(1);
|
||||
if (tok->str() != "=" || !tok->astOperand1() || !tok->astOperand2())
|
||||
continue;
|
||||
if (!tok->scope()->isExecutable())
|
||||
|
|
|
@ -2762,6 +2762,14 @@ private:
|
|||
"}";
|
||||
values = tokenValues(code, "==");
|
||||
ASSERT_EQUALS(true, values.empty());
|
||||
|
||||
// for loops
|
||||
code = "struct S { int x; };\n" // #9036
|
||||
"void foo(struct S s) {\n"
|
||||
" for (s.x = 0; s.x < 127; s.x++) {}\n"
|
||||
"}";
|
||||
values = tokenValues(code, "<"); // TODO: comparison can be true or false
|
||||
ASSERT_EQUALS(true, values.empty());
|
||||
}
|
||||
|
||||
void valueFlowSwitchVariable() {
|
||||
|
|
Loading…
Reference in New Issue