fixed false positive for 'using bitwise operation on boolean result'
This commit is contained in:
parent
72b01d1ca0
commit
314d5f1e79
|
@ -165,7 +165,7 @@ void CheckOther::clarifyCondition()
|
||||||
// using boolean result in bitwise operation ! x [&|^]
|
// using boolean result in bitwise operation ! x [&|^]
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if (Token::Match(tok, "!|<|<=|==|!=|>|>="))
|
if (Token::Match(tok, "!|<|<=|==|!=|>|>= !!&"))
|
||||||
{
|
{
|
||||||
const Token *tok2 = tok->next();
|
const Token *tok2 = tok->next();
|
||||||
while (tok2 && (tok2->isName() || tok2->isNumber() || Token::Match(tok2,".|(|[")))
|
while (tok2 && (tok2->isName() || tok2->isNumber() || Token::Match(tok2,".|(|[")))
|
||||||
|
|
|
@ -2670,6 +2670,9 @@ private:
|
||||||
" if (x == foo() & 2) {}\n"
|
" 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());
|
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()
|
void incorrectStringCompare()
|
||||||
|
|
Loading…
Reference in New Issue