From 21c22d0d4dee7e52f42cc0cee96955a922b08f98 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Tue, 26 Feb 2019 17:14:45 +0100 Subject: [PATCH] TestNullPointer: add regression test to cover #8813 (#1699) ... which is fixed since 1.86-72-gbc34f0239 --- test/testnullpointer.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 38a563759..1c2537124 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -1098,6 +1098,22 @@ private: "}"); ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:5]: (warning) Either the condition 'p' is redundant or there is possible null pointer dereference: p.\n", errout.str()); } + + // ticket #8831 - FP triggered by if/return/else sequence + { + check("void f(int *p, int *q) {\n" + " if (p == NULL)\n" + " return;\n" + " else if (q == NULL)\n" + " return;\n" + " *q = 0;\n" + "}\n" + "\n" + "void g() {\n" + " f(NULL, NULL);\n" + "}", true); + ASSERT_EQUALS("", errout.str()); + } } // Ticket #2350