Skip to content

Commit bd63882

Browse files
committed
testuninitvar: #9735 - Moved test to valueFlowUninit.
1 parent 8c9c468 commit bd63882

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

test/testuninitvar.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4516,6 +4516,28 @@ class TestUninitVar : public TestFixture {
45164516
}
45174517

45184518
void valueFlowUninit() {
4519+
// #9735 - FN
4520+
ctu("typedef struct\n"
4521+
"{\n"
4522+
" int x;\n"
4523+
" unsigned int flag : 1;\n"// bit filed gets never initialized
4524+
"} status;\n"
4525+
"bool foo(const status * const s)\n"
4526+
"{\n"
4527+
" return s->flag;\n"// << uninitvar
4528+
"}\n"
4529+
"void bar(const status * const s)\n"
4530+
"{\n"
4531+
" if( foo(s) == 1) {;}\n"
4532+
"}\n"
4533+
"void f(void)\n"
4534+
"{\n"
4535+
" status s;\n"
4536+
" s.x = 42;\n"
4537+
" bar(&s);\n"
4538+
"}");
4539+
ASSERT_EQUALS("[test.cpp:18] -> [test.cpp:12] -> [test.cpp:8]: (error) Using argument s that points at uninitialized variable s\n", errout.str());
4540+
45194541
// Ticket #2207 - False negative
45204542
valueFlowUninit("void foo() {\n"
45214543
" int a;\n"
@@ -5946,28 +5968,6 @@ class TestUninitVar : public TestFixture {
59465968
}
59475969

59485970
void ctu() {
5949-
// #9735 - FN
5950-
ctu("typedef struct\n"
5951-
"{\n"
5952-
" int x;\n"
5953-
" unsigned int flag : 1;\n" // bit filed gets never initialized
5954-
"} status;\n"
5955-
"bool foo(const status * const s)\n"
5956-
"{\n"
5957-
" return s->flag;\n" // << uninitvar
5958-
"}\n"
5959-
"void bar(const status * const s)\n"
5960-
"{\n"
5961-
" if( foo(s) == 1) {;}\n"
5962-
"}\n"
5963-
"void f(void)\n"
5964-
"{\n"
5965-
" status s;\n"
5966-
" s.x = 42;\n"
5967-
" bar(&s);\n"
5968-
"}");
5969-
ASSERT_EQUALS("[test.cpp:18] -> [test.cpp:12] -> [test.cpp:8]: (error) Using argument s that points at uninitialized variable s\n", errout.str());
5970-
59715971
ctu("void f(int *p) {\n"
59725972
" a = *p;\n"
59735973
"}\n"

0 commit comments

Comments
 (0)