Fixed #6908 (False positive: Same expression on both sides of '+='.)
This commit is contained in:
parent
ec3d76be5e
commit
c9e239afbf
|
@ -2025,7 +2025,7 @@ void CheckOther::checkDuplicateExpression()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (tok->isOp() && tok->astOperand1() && !Token::Match(tok, "+|*|<<|>>")) {
|
if (tok->isOp() && tok->astOperand1() && !Token::Match(tok, "+|*|<<|>>|+=|*=|<<=|>>=")) {
|
||||||
if (Token::Match(tok, "==|!=|-") && astIsFloat(tok->astOperand1(), true))
|
if (Token::Match(tok, "==|!=|-") && astIsFloat(tok->astOperand1(), true))
|
||||||
continue;
|
continue;
|
||||||
if (isSameExpression(_tokenizer->isCPP(), tok->astOperand1(), tok->astOperand2(), _settings->library.functionpure)) {
|
if (isSameExpression(_tokenizer->isCPP(), tok->astOperand1(), tok->astOperand2(), _settings->library.functionpure)) {
|
||||||
|
|
|
@ -4137,6 +4137,9 @@ private:
|
||||||
check("int f(int x) { return x+x; }");
|
check("int f(int x) { return x+x; }");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f(int x) { while (x+=x) ; }");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" if (a && b && b) {}\n"
|
" if (a && b && b) {}\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
Loading…
Reference in New Issue