Add regression test for #10215 (#3317)

This commit is contained in:
chrchr-github 2021-06-29 19:42:47 +02:00 committed by GitHub
parent 10123b4ad2
commit 5b1420ff64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 2 deletions

View File

@ -112,7 +112,8 @@ private:
TEST_CASE(nullpointer69); // #8143
TEST_CASE(nullpointer70);
TEST_CASE(nullpointer71); // #10178
TEST_CASE(nullpointer72); // #10321
TEST_CASE(nullpointer72); // #10215
TEST_CASE(nullpointer73); // #10321
TEST_CASE(nullpointer_addressOf); // address of
TEST_CASE(nullpointerSwitch); // #2626
TEST_CASE(nullpointer_cast); // #4692
@ -2240,7 +2241,27 @@ private:
ASSERT_EQUALS("", errout.str());
}
void nullpointer72() {
void nullpointer72() { // #10215
check("int test() {\n"
"int* p0 = nullptr, *p1 = nullptr;\n"
"getFoo(p0);\n"
"getBar(p1);\n"
"if (!(p0 != nullptr && p1 != nullptr))\n"
"return {};\n"
"return *p0 + *p1;\n"
"}\n", true /*inconclusive*/);
ASSERT_EQUALS("", errout.str());
check("int test2() {\n"
"int* p0 = nullptr; \n"
"if (!(getBaz(p0) && p0 != nullptr))\n"
"return 0;\n"
"return *p0;\n"
"}\n", true /*inconclusive*/);
ASSERT_EQUALS("", errout.str());
}
void nullpointer73() {
check("void f(bool flag2, int* ptr) {\n"
" bool flag1 = true;\n"
" if (flag2) {\n"