Fixed #5334 (False positive: same expression on both sides of '||')
This commit is contained in:
parent
eaf8c83db5
commit
ceca6be22b
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue