Fixed #5334 (False positive: same expression on both sides of '||')

This commit is contained in:
Daniel Marjamäki 2014-01-11 15:15:01 +01:00
parent eaf8c83db5
commit ceca6be22b
2 changed files with 10 additions and 0 deletions

View File

@ -67,6 +67,9 @@ static bool isSameExpression(const Token *tok1, const Token *tok2, const std::se
else if (tok1->function() && !tok1->function()->isConst)
return false;
}
if ((Token::Match(tok1, "%var% <") && tok1->next()->link()) ||
(Token::Match(tok2, "%var% <") && tok2->next()->link()))
return false;
if (Token::Match(tok1, "++|--"))
return false;
if (tok1->str() == "(" && tok1->previous() && !tok1->previous()->isName()) { // cast => assert that the casts are equal

View File

@ -3695,6 +3695,13 @@ private:
);
ASSERT_EQUALS("", errout.str());
// #5334
check("void f(C *src) {\n"
" if (x<A*>(src) || x<B*>(src))\n"
" a++;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(int x) {\n"
" if ((x == 1) && (x == 0x00000001))\n"
" a++;\n"