Skip to content

Commit

Permalink
Add test for #11534
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Dec 6, 2023
1 parent e766fba commit 4f0391c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/testnullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class TestNullPointer : public TestFixture {
TEST_CASE(nullpointer99); // #10602
TEST_CASE(nullpointer100); // #11636
TEST_CASE(nullpointer101); // #11382
TEST_CASE(nullpointer102);
TEST_CASE(nullpointer_addressOf); // address of
TEST_CASE(nullpointerSwitch); // #2626
TEST_CASE(nullpointer_cast); // #4692
Expand Down Expand Up @@ -2843,6 +2844,20 @@ class TestNullPointer : public TestFixture {
ASSERT_EQUALS("", errout.str());
}

void nullpointer102()
{
check("struct S { std::string str; };\n" // #11534
"struct T { S s; };\n"
"struct U { T t[1]; };\n"
"void f(const T& t, const U& u, std::string& str) {\n"
" if (str.empty())\n"
" str = t.s.str;\n"
" else\n"
" str = u.t[0].s.str;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void nullpointer_addressOf() { // address of
check("void f() {\n"
" struct X *x = 0;\n"
Expand Down

0 comments on commit 4f0391c

Please sign in to comment.