Skip to content

Commit ed64bc4

Browse files
Update checkcondition.cpp
1 parent 2fc869a commit ed64bc4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/checkcondition.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,11 @@ void CheckCondition::alwaysTrueFalse()
15401540
{
15411541
// is this a condition..
15421542
const Token *parent = tok->astParent();
1543-
while (Token::Match(parent, "%oror%|&&"))
1543+
bool hasComp = false;
1544+
while (Token::Match(parent, "%oror%|&&")) {
1545+
hasComp = true;
15441546
parent = parent->astParent();
1547+
}
15451548
if (!parent)
15461549
continue;
15471550
if (parent->str() == "?" && precedes(tok, parent))
@@ -1555,10 +1558,11 @@ void CheckCondition::alwaysTrueFalse()
15551558
condition = parent->astParent()->astParent()->previous();
15561559
else if (Token::Match(tok, "%comp%"))
15571560
condition = tok;
1558-
else if (tok->str() == "(" && astIsBool(parent) && Token::Match(parent, "%assign%"))
1561+
else if ((tok->str() == "(" || (hasComp && Token::Match(tok, "!|%var%"))) && astIsBool(parent) && Token::Match(parent, "%assign%"))
15591562
condition = tok;
15601563
else
15611564
continue;
1565+
15621566
}
15631567
// Skip already diagnosed values
15641568
if (diag(tok, false))

0 commit comments

Comments
 (0)