#9772: FP uninitvar: in cppcheck 2.1; Added a regression to test

This commit is contained in:
orbitcowboy 2021-07-06 14:24:07 +02:00
parent f3365a874f
commit 7d7241b076
1 changed files with 23 additions and 0 deletions

View File

@ -73,6 +73,7 @@ private:
TEST_CASE(uninitvar10); // ticket #9467
TEST_CASE(uninitvar11); // ticket #9123
TEST_CASE(uninitvar12); // #10218 - stream read
TEST_CASE(uninitvar13); // #9772
TEST_CASE(uninitvar_unconditionalTry);
TEST_CASE(uninitvar_funcptr); // #6404
TEST_CASE(uninitvar_operator); // #6680
@ -2995,6 +2996,28 @@ private:
ASSERT_EQUALS("", errout.str());
}
void uninitvar13() { // #9772 - FP
const char code[] = "int func(void)\n"
"{ int rez;\n"
" struct sccb* ccb;\n"
" \n"
" do\n"
" { if ((ccb = calloc(1, sizeof(*ccb))) == NULL)\n"
" { rez = 1;\n"
" break;\n"
" }\n"
" rez = 0;\n"
" } while (0);\n"
" \n"
" if (rez != 0)\n"
" free(ccb);\n"
" \n"
" return rez;\n"
"}";
checkUninitVar(code);
ASSERT_EQUALS("", errout.str());
}
void uninitvar_unconditionalTry() {
// Unconditional scopes and try{} scopes
checkUninitVar("int f() {\n"