Amend test cases for #10215 (#3420)

This commit is contained in:
chrchr-github 2021-08-26 19:37:04 +02:00 committed by GitHub
parent d9b6940070
commit b2852de456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 10 deletions

View File

@ -2268,20 +2268,30 @@ private:
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"
" 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"
" int* p0 = nullptr;\n"
" if (!(getBaz(p0) && p0 != nullptr))\n"
" return 0;\n"
" return *p0;\n"
"}\n", true /*inconclusive*/);
ASSERT_EQUALS("", errout.str());
check("int test3() {\n"
" Obj* PObj = nullptr;\n"
" if (!(GetObj(PObj) && PObj != nullptr))\n"
" return 1;\n"
" if (!PObj->foo())\n"
" test();\n"
" PObj->bar();\n"
"}\n", true /*inconclusive*/);
ASSERT_EQUALS("", errout.str());
}