Skip to content

Commit 7ceb51a

Browse files
committed
Try to improve 'clarifyStatement' warning message
1 parent 16bed07 commit 7ceb51a

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void CheckOther::clarifyStatement()
224224

225225
void CheckOther::clarifyStatementError(const Token *tok)
226226
{
227-
reportError(tok, Severity::warning, "clarifyStatement", "Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n"
227+
reportError(tok, Severity::warning, "clarifyStatement", "In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n"
228228
"A statement like '*A++;' might not do what you intended. Postfix 'operator++' is executed before 'operator*'. "
229229
"Thus, the dereference is meaningless. Did you intend to write '(*A)++;'?", CWE783, false);
230230
}

test/testother.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,28 +3384,28 @@ class TestOther : public TestFixture {
33843384
" *c++;\n"
33853385
" return c;\n"
33863386
"}");
3387-
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
3387+
ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str());
33883388

33893389
check("char* f(char** c) {\n"
33903390
" *c[5]--;\n"
33913391
" return *c;\n"
33923392
"}");
3393-
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
3393+
ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str());
33943394

33953395
check("void f(Foo f) {\n"
33963396
" *f.a++;\n"
33973397
"}");
3398-
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
3398+
ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str());
33993399

34003400
check("void f(Foo f) {\n"
34013401
" *f.a[5].v[3]++;\n"
34023402
"}");
3403-
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
3403+
ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str());
34043404

34053405
check("void f(Foo f) {\n"
34063406
" *f.a(1, 5).v[x + y]++;\n"
34073407
"}");
3408-
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
3408+
ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str());
34093409

34103410
check("char* f(char* c) {\n"
34113411
" (*c)++;\n"
@@ -3422,13 +3422,13 @@ class TestOther : public TestFixture {
34223422
" ***c++;\n"
34233423
" return c;\n"
34243424
"}");
3425-
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
3425+
ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str());
34263426

34273427
check("char** f(char*** c) {\n"
34283428
" **c[5]--;\n"
34293429
" return **c;\n"
34303430
"}");
3431-
ASSERT_EQUALS("[test.cpp:2]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'?\n", errout.str());
3431+
ASSERT_EQUALS("[test.cpp:2]: (warning) In expression like '*A++' the result of '*' is unused. Did you intend to write '(*A)++;'?\n", errout.str());
34323432

34333433
check("char*** f(char*** c) {\n"
34343434
" (***c)++;\n"

0 commit comments

Comments
 (0)