Added testcases for #3098

This commit is contained in:
Ettl Martin 2012-09-09 19:49:40 +02:00
parent d3bdd84d8b
commit f1faaac1f2
1 changed files with 33 additions and 0 deletions

View File

@ -842,6 +842,39 @@ private:
" { }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// Ticket #3098 - False negative uninitialized variable
checkUninitVar("void f()\n"
"{\n"
" char *c1,*c2;\n"
" if(strcoll(c1,c2))\n"
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: c1\n"
"[test.cpp:4]: (error) Uninitialized variable: c2\n", errout.str());
checkUninitVar("void f(char *c1, char *c2)\n"
"{\n"
" if(strcoll(c1,c2))\n"
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n"
"{\n"
" char *c1;\n"
" c1=strcpy(c1,\"test\");\n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: c1\n","", errout.str());
checkUninitVar("void f(char *c1)\n"
"{\n"
" c1=strcpy(c1,\"test\");\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}