diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ca578ceae..3c7e7b3b6 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2782,7 +2782,9 @@ void CheckOther::checkDuplicateExpression() const Token *ast1 = tok->astOperand1(); while (ast1 && tok->str() == ast1->str()) { if (isSameExpression(ast1->astOperand1(), tok->astOperand2(), _settings->library.functionpure)) - duplicateExpressionError(ast1->astOperand1(), tok->astOperand2(), tok->str()); + // TODO: warn if variables are unchanged. See #5683 + // Probably the message should be changed to 'duplicate expressions X in condition or something like that'. + ;//duplicateExpressionError(ast1->astOperand1(), tok->astOperand2(), tok->str()); else if (isSameExpression(ast1->astOperand2(), tok->astOperand2(), _settings->library.functionpure)) duplicateExpressionError(ast1->astOperand2(), tok->astOperand2(), tok->str()); if (!isConstExpression(ast1->astOperand2(), _settings->library.functionpure)) diff --git a/test/testother.cpp b/test/testother.cpp index e8a151d82..53bd28c87 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4630,7 +4630,12 @@ private: check("void foo() {\n" " if (x!=2 || y!=3 || x!=2) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Same expression on both sides of '||'.\n", errout.str()); + TODO_ASSERT_EQUALS("error", "", errout.str()); + + check("void foo() {\n" + " if (x!=2 && (x=y) && x!=2) {}\n" + "}"); + ASSERT_EQUALS("", errout.str()); check("void foo() {\n" " if (a && b || a && b) {}\n"