Fixed #6249 (False positive: Incorrect detection of (assignment + comparison) inside for-clause)

This commit is contained in:
Daniel Marjamäki 2015-02-05 20:17:30 +01:00
parent f19d4afcde
commit eec938dbad
2 changed files with 6 additions and 1 deletions

View File

@ -781,7 +781,8 @@ void CheckCondition::clarifyCondition()
// This might be a template
if (!isC && tok2->link())
break;
if (Token::simpleMatch(tok2->astParent(), "?"))
break;
clarifyConditionError(tok, tok->strAt(2) == "=", false);
break;
} else if (!tok2->isName() && !tok2->isNumber() && tok2->str() != ".")

View File

@ -1213,6 +1213,10 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" if (x = b < 0 ? 1 : 2) {}\n" // don't simplify and verify this code
"}", false);
ASSERT_EQUALS("", errout.str());
}
// clarify conditions with bitwise operator and comparison