parent
d6d3c7b3fc
commit
218650dc85
|
@ -1458,10 +1458,10 @@ bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2
|
|||
tok2 = tok2->astOperand2();
|
||||
}
|
||||
// Skip double not
|
||||
if (Token::simpleMatch(tok1, "!") && Token::simpleMatch(tok1->astOperand1(), "!") && !Token::simpleMatch(tok1->astParent(), "=")) {
|
||||
if (Token::simpleMatch(tok1, "!") && Token::simpleMatch(tok1->astOperand1(), "!") && !Token::simpleMatch(tok1->astParent(), "=") && astIsBoolLike(tok2)) {
|
||||
return isSameExpression(cpp, macro, tok1->astOperand1()->astOperand1(), tok2, library, pure, followVar, errors);
|
||||
}
|
||||
if (Token::simpleMatch(tok2, "!") && Token::simpleMatch(tok2->astOperand1(), "!") && !Token::simpleMatch(tok2->astParent(), "=")) {
|
||||
if (Token::simpleMatch(tok2, "!") && Token::simpleMatch(tok2->astOperand1(), "!") && !Token::simpleMatch(tok2->astParent(), "=") && astIsBoolLike(tok1)) {
|
||||
return isSameExpression(cpp, macro, tok1, tok2->astOperand1()->astOperand1(), library, pure, followVar, errors);
|
||||
}
|
||||
const bool tok_str_eq = tok1->str() == tok2->str();
|
||||
|
|
|
@ -6570,6 +6570,15 @@ private:
|
|||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) The comparison 'p == 0' is always true.\n", errout.str());
|
||||
|
||||
// #11820
|
||||
check("unsigned f(unsigned x) {\n"
|
||||
" return x - !!x;\n"
|
||||
"}\n"
|
||||
"unsigned g(unsigned x) {\n"
|
||||
" return !!x - x;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void duplicateExpression8() {
|
||||
|
|
Loading…
Reference in New Issue