Skip to content

Commit 2c73f8f

Browse files
committed
Add tests
1 parent e06e98f commit 2c73f8f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/testunusedvar.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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

73297350
REGISTER_TEST(TestUnusedVar)

0 commit comments

Comments
 (0)