File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -271,6 +271,9 @@ class TestUnusedVar : public TestFixture {
271271 TEST_CASE (globalData);
272272
273273 TEST_CASE (structuredBinding); // #13269
274+
275+ TEST_CASE (pointerCast1); // #14535
276+ TEST_CASE (pointerCast2);
274277 }
275278
276279 struct FunctionVariableUsageOptions
@@ -7324,6 +7327,24 @@ class TestUnusedVar : public TestFixture {
73247327 " }\n " );
73257328 ASSERT_EQUALS (" " , errout_str ());
73267329 }
7330+
7331+ void pointerCast1 () { // #14535
7332+ functionVariableUsage (" void f(int* p)\n "
7333+ " {\n "
7334+ " int* p2 = p;\n "
7335+ " ((int *)(p2))[0] = 0;\n "
7336+ " }\n " );
7337+ ASSERT_EQUALS (" " , errout_str ());
7338+ }
7339+
7340+ void pointerCast2 () {
7341+ functionVariableUsage (" void f(int* p)\n "
7342+ " {\n "
7343+ " int* p2 = p;\n "
7344+ " static_cast<int*>(p2)[0] = 0;\n "
7345+ " }\n " );
7346+ ASSERT_EQUALS (" " , errout_str ());
7347+ }
73277348};
73287349
73297350REGISTER_TEST (TestUnusedVar)
You can’t perform that action at this time.
0 commit comments