Add regression test for issue 9264: FP nullPointerRedundantCheck - pointer alias (#2133)

This commit is contained in:
Paul Fultz II 2019-09-01 02:58:53 -05:00 committed by Daniel Marjamäki
parent 3a1aec8850
commit 9ef64eb33e
1 changed files with 13 additions and 0 deletions

View File

@ -75,6 +75,7 @@ private:
TEST_CASE(nullpointer33);
TEST_CASE(nullpointer34);
TEST_CASE(nullpointer35);
TEST_CASE(nullpointer36); // #9264
TEST_CASE(nullpointer_addressOf); // address of
TEST_CASE(nullpointerSwitch); // #2626
TEST_CASE(nullpointer_cast); // #4692
@ -1427,6 +1428,18 @@ private:
ASSERT_EQUALS("", errout.str());
}
void nullpointer36() {
check("char* f(char* s) {\n"
" char* start = s;\n"
" if (!s)\n"
" return (s);\n"
" while (isspace(*start))\n"
" start++;\n"
" return (start);\n"
"}\n", true);
ASSERT_EQUALS("", errout.str());
}
void nullpointer_addressOf() { // address of
check("void f() {\n"
" struct X *x = 0;\n"