AST: Improved 'same expression on both sides of operator' checking for nested operators
This commit is contained in:
parent
203d3e916b
commit
d1721b9d1b
|
@ -3348,6 +3348,8 @@ void CheckOther::checkDuplicateExpression()
|
|||
continue;
|
||||
if (isSameExpression(tok->astOperand1(), tok->astOperand2(), constStandardFunctions))
|
||||
duplicateExpressionError(tok, tok, tok->str());
|
||||
else if (tok->astOperand1() && tok->str() == tok->astOperand1()->str() && isSameExpression(tok->astOperand2(), tok->astOperand1()->astOperand2(), constStandardFunctions))
|
||||
duplicateExpressionError(tok->astOperand2(), tok->astOperand2(), tok->str());
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
|
|
@ -4779,6 +4779,12 @@ private:
|
|||
|
||||
check("int f(int x) { return x+x; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo() {\n"
|
||||
" if (a && b && b) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Same expression on both sides of '&&'.\n", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void duplicateIf1() { // ticket 3689 ( avoid false positive )
|
||||
|
|
Loading…
Reference in New Issue