File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ))
You can’t perform that action at this time.
0 commit comments