From d539cf59caa4e53101b8861f95520af42e2e9444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 28 Mar 2011 19:27:07 +0200 Subject: [PATCH] Null pointer: Added TODO test case for ticket #2681 --- test/testnullpointer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 3b851c9c8..16d609211 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -80,6 +80,17 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 3\n", errout.str()); + // #2681 + check("void foo(const Token *tok)\n" + "{\n" + " while (tok && tok->str() == \"=\")\n" + " tok = tok->tokAt(-2);\n" + "\n" + " if (tok->str() != \";\")\n" + " ;\n" + "}\n"); + TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 3\n", "", errout.str()); + check("void foo()\n" "{\n" " for (const Token *tok = tokens; tok; tok = tok->next())\n"