Same expression: don't warn for same expressions when there is assignment
This commit is contained in:
parent
69fbf50081
commit
cb43bee10d
|
@ -114,7 +114,7 @@ bool isSameExpression(const Token *tok1, const Token *tok2, const std::set<std::
|
||||||
if (t1 != end1 || t2 != end2)
|
if (t1 != end1 || t2 != end2)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Token::Match(tok1, "++|--"))
|
if (Token::Match(tok1, "++|--") || tok1->isAssignmentOp())
|
||||||
return false;
|
return false;
|
||||||
if (tok1->str() == "(" && tok1->previous() && !tok1->previous()->isName()) { // cast => assert that the casts are equal
|
if (tok1->str() == "(" && tok1->previous() && !tok1->previous()->isName()) { // cast => assert that the casts are equal
|
||||||
const Token *t1 = tok1->next();
|
const Token *t1 = tok1->next();
|
||||||
|
|
|
@ -4974,6 +4974,12 @@ private:
|
||||||
" if (*a-- != b || *a-- != b) {}\n"
|
" if (*a-- != b || *a-- != b) {}\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// assignment
|
||||||
|
check("void f() {\n"
|
||||||
|
" while (*(a+=2)==*(b+=2) && *(a+=2)==*(b+=2)) {}\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void duplicateExpression5() { // #3749 - macros with same values
|
void duplicateExpression5() { // #3749 - macros with same values
|
||||||
|
|
Loading…
Reference in New Issue