todo tests for #2812 (false negative: null pointer dereference when returning struct member)

This commit is contained in:
Robert Reif 2011-06-03 22:16:08 -04:00
parent 0f6da27b9f
commit e9bc72b4f2
1 changed files with 19 additions and 0 deletions

View File

@ -45,6 +45,7 @@ private:
TEST_CASE(nullpointer8);
TEST_CASE(nullpointer9);
TEST_CASE(nullpointer10);
TEST_CASE(nullpointer11); // ticket #2812
TEST_CASE(pointerCheckAndDeRef); // check if pointer is null and then dereference it
TEST_CASE(nullConstantDereference); // Dereference NULL constant
TEST_CASE(gcc_statement_expression); // Don't crash
@ -888,6 +889,16 @@ private:
" p->x = 0;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", errout.str());
}
void nullpointer11() // ticket #2812
{
check("int foo()\n"
"{\n"
" my_type* p = 0;\n"
" return p->x;\n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: p\n", "", errout.str());
check("int foo()\n"
"{\n"
@ -896,6 +907,14 @@ private:
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: p\n", "", errout.str());
check("int foo()\n"
"{\n"
" my_type* p;\n"
" p = 0; \n"
" return p->x;\n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", "", errout.str());
check("int foo()\n"
"{\n"
" struct my_type* p;\n"