Null pointer: Added todo test case to better handle dereference in condition

This commit is contained in:
Daniel Marjamäki 2011-08-02 17:20:13 +02:00
parent 08f27564fa
commit 493cfa5df2
1 changed files with 7 additions and 0 deletions

View File

@ -429,6 +429,13 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 4\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 4\n", errout.str());
check("void foo(char *p)\n"
"{\n"
" if (*p == 0) { }\n"
" if (!p) { }\n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 4\n", "", errout.str());
// no error // no error
check("void foo()\n" check("void foo()\n"
"{\n" "{\n"