diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 41a1a6774..3822a06d2 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -127,7 +127,7 @@ void CheckOther::clarifyCalculationError(const Token *tok, char op) reportError(tok, Severity::style, "clarifyCalculation", - "Suspicious calculation, " + calc + " can be clarified as either " + s1 + " or " + s2 + "\n" + + std::string("Clarify calculation precedence for ") + op + " and ?\n" + "Suspicious calculation. Please use parentheses to clarify the code. " "The code " + calc + " should be written as either " + s1 + " or " + s2 + "."); } diff --git a/test/testother.cpp b/test/testother.cpp index 8126ad0a4..eff97d0ff 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2274,12 +2274,12 @@ private: check("int f(char c) {\n" " return 10 * (c == 0) ? 1 : 2;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious calculation, 'a*b?c:d' can be clarified as either '(a*b)?c:d' or 'a*(b?c:d)'\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Clarify calculation precedence for * and ?\n", errout.str()); check("void f(char c) {\n" " printf(\"%i\", 10 * (c == 0) ? 1 : 2);\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious calculation, 'a*b?c:d' can be clarified as either '(a*b)?c:d' or 'a*(b?c:d)'\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Clarify calculation precedence for * and ?\n", errout.str()); // Ticket #2585 - segmentation fault for invalid code check("abcdef?" "?<" @@ -2290,7 +2290,7 @@ private: check("void f(char c) {\n" " printf(\"%i\", 1 + 1 ? 1 : 2);\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious calculation, 'a+b?c:d' can be clarified as either '(a+b)?c:d' or 'a+(b?c:d)'\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Clarify calculation precedence for + and ?\n", errout.str()); } // clarify conditions with = and comparison