From 7ceb51a95202bc85e771081dbd9919b7c06a92bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 22 Jun 2019 08:44:41 +0200 Subject: [PATCH] Try to improve 'clarifyStatement' warning message --- lib/checkother.cpp | 2 +- test/testother.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ef9b573db..d54fe0dd9 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -224,7 +224,7 @@ void CheckOther::clarifyStatement() void CheckOther::clarifyStatementError(const Token *tok) { - reportError(tok, Severity::warning, "clarifyStatement", "Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n" + reportError(tok, Severity::warning, "clarifyStatement", "In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n" "A statement like '*A++;' might not do what you intended. Postfix 'operator++' is executed before 'operator*'. " "Thus, the dereference is meaningless. Did you intend to write '(*A)++;'?", CWE783, false); } diff --git a/test/testother.cpp b/test/testother.cpp index 6d4865fd6..af9229880 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3384,28 +3384,28 @@ private: " *c++;\n" " return c;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str()); check("char* f(char** c) {\n" " *c[5]--;\n" " return *c;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str()); check("void f(Foo f) {\n" " *f.a++;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str()); check("void f(Foo f) {\n" " *f.a[5].v[3]++;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str()); check("void f(Foo f) {\n" " *f.a(1, 5).v[x + y]++;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str()); check("char* f(char* c) {\n" " (*c)++;\n" @@ -3422,13 +3422,13 @@ private: " ***c++;\n" " return c;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str()); check("char** f(char*** c) {\n" " **c[5]--;\n" " return **c;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str()); check("char*** f(char*** c) {\n" " (***c)++;\n"