fixed false positive for 'using bitwise operation on boolean result'

This commit is contained in:
Daniel Marjamäki 2011-08-19 17:07:26 +02:00
parent 72b01d1ca0
commit 314d5f1e79
2 changed files with 4 additions and 1 deletions

View File

@ -165,7 +165,7 @@ void CheckOther::clarifyCondition()
// using boolean result in bitwise operation ! x [&|^]
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
if (Token::Match(tok, "!|<|<=|==|!=|>|>="))
if (Token::Match(tok, "!|<|<=|==|!=|>|>= !!&"))
{
const Token *tok2 = tok->next();
while (tok2 && (tok2->isName() || tok2->isNumber() || Token::Match(tok2,".|(|[")))

View File

@ -2670,6 +2670,9 @@ private:
" if (x == foo() & 2) {}\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses\n", errout.str());
check("void f(std::list<int> &ints) { }");
ASSERT_EQUALS("", errout.str());
}
void incorrectStringCompare()