From 5b1420ff641af2ff25418d171e7548c43bf33162 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 29 Jun 2021 19:42:47 +0200 Subject: [PATCH] Add regression test for #10215 (#3317) --- test/testnullpointer.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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"