Ticket #9735 - Added regression test

This commit is contained in:
orbitcowboy 2021-10-30 16:31:59 +02:00
parent 61a2b89034
commit be2ba0f772
1 changed files with 25 additions and 0 deletions

View File

@ -73,6 +73,7 @@ private:
TEST_CASE(uninitvar11); // ticket #9123
TEST_CASE(uninitvar12); // #10218 - stream read
TEST_CASE(uninitvar13); // #9772
TEST_CASE(uninitvar14); // #9735
TEST_CASE(uninitvar_unconditionalTry);
TEST_CASE(uninitvar_funcptr); // #6404
TEST_CASE(uninitvar_operator); // #6680
@ -3019,6 +3020,30 @@ private:
ASSERT_EQUALS("", errout.str());
}
void uninitvar14() { // #9735 - FN
const char code[] = "typedef struct\n"
"{\n"
" int x;\n"
" unsigned int flag : 1; // bit filed gets never initialized\n"
"} status;\n"
"bool foo(const status * const s)\n"
"{\n"
" return s->flag ;\n" // << uninitvar
"}\n"
"void bar(const status * const s)\n"
"{\n"
" if( foo(s) == 1) {;}\n"
"}\n"
"void f(void)\n"
"{\n"
" status s;\n"
" s.x = 42;\n"
" bar(&s);\n"
"}";
checkUninitVar(code);
ASSERT_EQUALS("", errout.str());
}
void uninitvar_unconditionalTry() {
// Unconditional scopes and try{} scopes
checkUninitVar("int f() {\n"