#6491: Added a regression test.

This commit is contained in:
Martin Ettl 2015-08-15 00:31:26 +02:00
parent 4fe61a6c3e
commit 640ec3a099
1 changed files with 12 additions and 0 deletions

View File

@ -70,6 +70,7 @@ private:
TEST_CASE(nullpointer25); // #5061
TEST_CASE(nullpointer26); // #3589
TEST_CASE(nullpointer27); // #6568
TEST_CASE(nullpointer28); // #6491
TEST_CASE(nullpointer_addressOf); // address of
TEST_CASE(nullpointerSwitch); // #2626
TEST_CASE(nullpointer_cast); // #4692
@ -1293,6 +1294,17 @@ private:
"[test.cpp:8]: (error) Null pointer dereference\n", errout.str());
}
void nullpointer28() { // #6491
check("typedef struct { int value; } S;\n"
"int f(const S *s) { \n"
" int i = s ? s->value + 1 \n"
" : s->value - 1; // <-- null ptr dereference \n"
" return i;\n"
"}\n"
"int main(){f(0);}\n", true);
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: s\n", errout.str());
}
void nullpointer_addressOf() { // address of
check("void f() {\n"
" struct X *x = 0;\n"