diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index cc289800a..22375664e 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4516,6 +4516,28 @@ private: } void valueFlowUninit() { + // #9735 - FN + ctu("typedef struct\n" + "{\n" + " int x;\n" + " unsigned int flag : 1;\n"// bit filed gets never initialized + "} 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" + "}"); + ASSERT_EQUALS("[test.cpp:18] -> [test.cpp:12] -> [test.cpp:8]: (error) Using argument s that points at uninitialized variable s\n", errout.str()); + // Ticket #2207 - False negative valueFlowUninit("void foo() {\n" " int a;\n" @@ -5946,28 +5968,6 @@ private: } void ctu() { - // #9735 - FN - ctu("typedef struct\n" - "{\n" - " int x;\n" - " unsigned int flag : 1;\n" // bit filed gets never initialized - "} 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" - "}"); - ASSERT_EQUALS("[test.cpp:18] -> [test.cpp:12] -> [test.cpp:8]: (error) Using argument s that points at uninitialized variable s\n", errout.str()); - ctu("void f(int *p) {\n" " a = *p;\n" "}\n"