diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 3be51772f..67342bbf7 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -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"