Fixed #6908 (False positive: Same expression on both sides of '+='.)

This commit is contained in:
Daniel Marjamäki 2015-08-07 20:28:25 +02:00
parent ec3d76be5e
commit c9e239afbf
2 changed files with 4 additions and 1 deletions

View File

@ -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)) {

View File

@ -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"
"}"); "}");