Null pointer: Added TODO test case for ticket #2681
This commit is contained in:
parent
a1dba61cee
commit
d539cf59ca
|
@ -80,6 +80,17 @@ private:
|
||||||
"}\n");
|
"}\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());
|
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"
|
check("void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" for (const Token *tok = tokens; tok; tok = tok->next())\n"
|
" for (const Token *tok = tokens; tok; tok = tok->next())\n"
|
||||||
|
|
Loading…
Reference in New Issue