This commit is contained in:
chrchr-github 2023-12-06 18:11:31 +01:00 committed by GitHub
parent 5761e55a67
commit 6aa3478243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -140,6 +140,7 @@ private:
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
@ -2843,6 +2844,20 @@ private:
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"