using boolean result in bitwise operation. fix false positive for '.. != (char *) &x'
This commit is contained in:
parent
2dd1e290eb
commit
a735790e77
|
@ -169,9 +169,16 @@ 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();
|
||||||
|
|
||||||
|
// Todo: There are false positives if '(' if encountered. It
|
||||||
|
// is assumed there is something like '(char *)&..' and therefore
|
||||||
|
// it bails out.
|
||||||
|
if (Token::Match(tok2, "(|&"))
|
||||||
|
continue;
|
||||||
|
|
||||||
while (tok2 && (tok2->isName() || tok2->isNumber() || Token::Match(tok2,".|(|[")))
|
while (tok2 && (tok2->isName() || tok2->isNumber() || Token::Match(tok2,".|(|[")))
|
||||||
{
|
{
|
||||||
if (Token::Match(tok2, "(|["))
|
if (Token::Match(tok2, "(|["))
|
||||||
|
|
|
@ -2682,6 +2682,11 @@ private:
|
||||||
|
|
||||||
check("void f() { A<x &> a; }");
|
check("void f() { A<x &> a; }");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" if (result != (char *)&inline_result) { }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void incorrectStringCompare()
|
void incorrectStringCompare()
|
||||||
|
|
Loading…
Reference in New Issue