@@ -180,9 +180,25 @@ class TestIncompleteStatement : public TestFixture {
180180 }
181181
182182 void void0 () { // #6327
183- check (" void f() { (void*)0; }" );
183+ check (" #define assert(x) ((void)0)\n "
184+ " void f(int* p) {\n "
185+ " assert(p);\n "
186+ " }\n " );
184187 ASSERT_EQUALS (" " , errout_str ());
185188
189+ check (" void f() { (void*)0; }" );
190+ ASSERT_EQUALS (" [test.cpp:1:12]: (warning) Redundant code: Found unused cast in expression '(void*)0'. [constStatement]\n " , errout_str ());
191+
192+ check (" void f() {\n " // #13148
193+ " static_cast<void>(1);\n "
194+ " static_cast<void>(nullptr);\n "
195+ " (void)NULL;\n "
196+ " }\n " );
197+ ASSERT_EQUALS (" [test.cpp:2:22]: (warning) Redundant code: Found unused cast in expression 'static_cast<void>(1)'. [constStatement]\n "
198+ " [test.cpp:3:22]: (warning) Redundant code: Found unused cast in expression 'static_cast<void>(nullptr)'. [constStatement]\n "
199+ " [test.cpp:4:5]: (warning) Redundant code: Found unused cast in expression '(void)NULL'. [constStatement]\n " ,
200+ errout_str ());
201+
186202 check (" #define X 0\n "
187203 " void f() { X; }" );
188204 ASSERT_EQUALS (" " , errout_str ());
@@ -432,11 +448,11 @@ class TestIncompleteStatement : public TestFixture {
432448 " }\n " , dinit (CheckOptions, $.inconclusive = true ));
433449 ASSERT_EQUALS (" [test.cpp:2:5]: (warning) Redundant code: Found a statement that begins with numeric constant. [constStatement]\n "
434450 " [test.cpp:3:6]: (warning) Redundant code: Found a statement that begins with numeric constant. [constStatement]\n "
435- " [test.cpp:4:5]: (warning) Redundant code: Found a statement that begins with numeric constant . [constStatement]\n "
436- " [test.cpp:5:6]: (warning) Redundant code: Found a statement that begins with numeric constant . [constStatement]\n "
451+ " [test.cpp:4:5]: (warning) Redundant code: Found unused cast in expression '(char)1' . [constStatement]\n "
452+ " [test.cpp:5:6]: (warning) Redundant code: Found unused cast in expression '(char)1' . [constStatement]\n "
437453 " [test.cpp:6:5]: (warning, inconclusive) Found suspicious operator '!', result is not used. [constStatement]\n "
438454 " [test.cpp:7:6]: (warning, inconclusive) Found suspicious operator '!', result is not used. [constStatement]\n "
439- " [test.cpp:8:5]: (warning) Redundant code: Found unused cast of expression '!x'. [constStatement]\n "
455+ " [test.cpp:8:5]: (warning) Redundant code: Found unused cast in expression '(unsigned int) !x'. [constStatement]\n "
440456 " [test.cpp:9:5]: (warning, inconclusive) Found suspicious operator '~', result is not used. [constStatement]\n " ,
441457 errout_str ());
442458
@@ -447,7 +463,7 @@ class TestIncompleteStatement : public TestFixture {
447463 ASSERT_EQUALS (" " , errout_str ());
448464
449465 check (" void f(int x) { static_cast<unsigned>(x); }" );
450- ASSERT_EQUALS (" [test.cpp:1:38]: (warning) Redundant code: Found unused cast of expression 'x '. [constStatement]\n " , errout_str ());
466+ ASSERT_EQUALS (" [test.cpp:1:38]: (warning) Redundant code: Found unused cast in expression 'static_cast<unsigned int>(x) '. [constStatement]\n " , errout_str ());
451467
452468 check (" void f(int x, int* p) {\n "
453469 " static_cast<void>(x);\n "
@@ -465,9 +481,9 @@ class TestIncompleteStatement : public TestFixture {
465481 " static_cast<float>((char)i);\n "
466482 " (char)static_cast<float>(i);\n "
467483 " }\n " );
468- ASSERT_EQUALS (" [test.cpp:2:5]: (warning) Redundant code: Found unused cast of expression 'i'. [constStatement]\n "
469- " [test.cpp:3:23]: (warning) Redundant code: Found unused cast of expression 'i '. [constStatement]\n "
470- " [test.cpp:4:5]: (warning) Redundant code: Found unused cast of expression 'i '. [constStatement]\n " ,
484+ ASSERT_EQUALS (" [test.cpp:2:5]: (warning) Redundant code: Found unused cast in expression '(float)(char) i'. [constStatement]\n "
485+ " [test.cpp:3:23]: (warning) Redundant code: Found unused cast in expression 'static_cast<float>((char)i) '. [constStatement]\n "
486+ " [test.cpp:4:5]: (warning) Redundant code: Found unused cast in expression '(char)static_cast<float>(i) '. [constStatement]\n " ,
471487 errout_str ());
472488
473489 check (" namespace M {\n "
@@ -476,7 +492,7 @@ class TestIncompleteStatement : public TestFixture {
476492 " void f(int i) {\n "
477493 " (M::N::T)i;\n "
478494 " }\n " );
479- ASSERT_EQUALS (" [test.cpp:5:5]: (warning) Redundant code: Found unused cast of expression 'i'. [constStatement]\n " , errout_str ());
495+ ASSERT_EQUALS (" [test.cpp:5:5]: (warning) Redundant code: Found unused cast in expression '(char) i'. [constStatement]\n " , errout_str ());
480496
481497 check (" void f(int (g)(int a, int b)) {\n " // #10873
482498 " int p = 0, q = 1;\n "
@@ -528,7 +544,7 @@ class TestIncompleteStatement : public TestFixture {
528544 " for (L\" y\" ; ;) {}\n "
529545 " }\n " );
530546 ASSERT_EQUALS (" [test.cpp:2:10]: (warning) Unused variable value 'i' [constStatement]\n "
531- " [test.cpp:3:10]: (warning) Redundant code: Found unused cast of expression 'i'. [constStatement]\n "
547+ " [test.cpp:3:10]: (warning) Redundant code: Found unused cast in expression '(long) i'. [constStatement]\n "
532548 " [test.cpp:4:10]: (warning) Redundant code: Found a statement that begins with numeric constant. [constStatement]\n "
533549 " [test.cpp:5:10]: (warning) Redundant code: Found a statement that begins with bool constant. [constStatement]\n "
534550 " [test.cpp:6:10]: (warning) Redundant code: Found a statement that begins with character constant. [constStatement]\n "
@@ -696,8 +712,8 @@ class TestIncompleteStatement : public TestFixture {
696712 " NULL;\n "
697713 " nullptr;\n "
698714 " }\n " );
699- ASSERT_EQUALS (" [test.cpp:2:5]: (warning) Redundant code: Found a statement that begins with NULL constant. [constStatement]\n "
700- " [test.cpp:3:5]: (warning) Redundant code: Found a statement that begins with NULL constant. [constStatement]\n " ,
715+ ASSERT_EQUALS (" [test.cpp:2:5]: (warning) Redundant code: Found a statement that begins with null constant. [constStatement]\n "
716+ " [test.cpp:3:5]: (warning) Redundant code: Found a statement that begins with null constant. [constStatement]\n " ,
701717 errout_str ());
702718
703719 check (" struct S { int i; };\n " // #6504
0 commit comments