diff --git a/lib/checkassignif.cpp b/lib/checkassignif.cpp index 7e2062d2c..fcf1f0273 100644 --- a/lib/checkassignif.cpp +++ b/lib/checkassignif.cpp @@ -117,7 +117,11 @@ void CheckAssignIf::comparisonError(const Token *tok, int value1, const std::str std::ostringstream expression; expression << std::hex << "(X & 0x" << value1 << ") " << op << " 0x" << value2; - const std::string errmsg("Expression '" + expression.str() + "' is always " + (result?"true":"false") + ". Look again at the constants."); + const std::string errmsg("Expression '" + expression.str() + "' is always " + (result?"true":"false") + "\n" + "The expression '" + expression.str() + "' is always " + (result?"true":"false") + + ". Check carefully constants and operators used, these errors might be hard to " + "spot sometimes. In case of complex expression it might help to split it to " + "separate expressions."); reportError(tok, Severity::style, "comparisonError", errmsg); } diff --git a/test/testassignif.cpp b/test/testassignif.cpp index a8ab3a419..aee94dafd 100644 --- a/test/testassignif.cpp +++ b/test/testassignif.cpp @@ -94,19 +94,19 @@ private: "{\n" " if (x & 4 == 3);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false. Look again at the constants.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false\n", errout.str()); check("void foo(int x)\n" "{\n" " if ((x & 4) == 3);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false. Look again at the constants.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) == 0x3' is always false\n", errout.str()); check("void foo(int x)\n" "{\n" " if (x & 4 != 3);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) != 0x3' is always true. Look again at the constants.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style) Expression '(X & 0x4) != 0x3' is always true\n", errout.str()); } void multicompare() {