Merge pull request #485 from orbitcowboy/master

testuninitvar: changed test cases to do not rely on ExecutionPath.
This commit is contained in:
Martin Ettl 2014-12-16 08:09:01 +01:00
commit 119aa5092a
1 changed files with 401 additions and 396 deletions

View File

@ -624,7 +624,7 @@ private:
void uninitvar3() { // #3844 void uninitvar3() { // #3844
// avoid false positive // avoid false positive
checkUninitVar("namespace std _GLIBCXX_VISIBILITY(default)\n" checkUninitVar2("namespace std _GLIBCXX_VISIBILITY(default)\n"
"{\n" "{\n"
"_GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n" "_GLIBCXX_BEGIN_NAMESPACE_CONTAINER\n"
" typedef unsigned long _Bit_type;\n" " typedef unsigned long _Bit_type;\n"
@ -640,13 +640,13 @@ private:
} }
void uninitvar_bitop() { void uninitvar_bitop() {
checkUninitVar("void foo() {\n" checkUninitVar2("void foo() {\n"
" int b;\n" " int b;\n"
" c = a | b;\n" " c = a | b;\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: b\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: b\n", errout.str());
checkUninitVar("void foo() {\n" checkUninitVar2("void foo() {\n"
" int b;\n" " int b;\n"
" c = b | a;\n" " c = b | a;\n"
"}"); "}");
@ -655,7 +655,7 @@ private:
// if.. // if..
void uninitvar_if() { void uninitvar_if() {
checkUninitVar("static void foo()\n" checkUninitVar2("static void foo()\n"
"{\n" "{\n"
" Foo *p;\n" " Foo *p;\n"
" if (x)\n" " if (x)\n"
@ -664,7 +664,7 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: p\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: p\n", errout.str());
checkUninitVar("static void foo(int x)\n" checkUninitVar2("static void foo(int x)\n"
"{\n" "{\n"
" int a;\n" " int a;\n"
" if (x==1);\n" " if (x==1);\n"
@ -673,7 +673,7 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: a\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: a\n", errout.str());
checkUninitVar("int foo()\n" checkUninitVar2("int foo()\n"
"{\n" "{\n"
" int i;\n" " int i;\n"
" if (x)\n" " if (x)\n"
@ -684,7 +684,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("int foo()\n" checkUninitVar2("int foo()\n"
"{\n" "{\n"
" int i;\n" " int i;\n"
" if (x)\n" " if (x)\n"
@ -714,7 +714,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("static void foo(int x)\n" checkUninitVar2("static void foo(int x)\n"
"{\n" "{\n"
" Foo *p;\n" " Foo *p;\n"
" if (x)\n" " if (x)\n"
@ -724,7 +724,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo(int a)\n" checkUninitVar2("void foo(int a)\n"
"{\n" "{\n"
" int n;\n" " int n;\n"
" int condition;\n" " int condition;\n"
@ -742,7 +742,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n" checkUninitVar2("void f()\n"
"{\n" "{\n"
" C *c;\n" " C *c;\n"
" if (fun(&c));\n" " if (fun(&c));\n"
@ -750,13 +750,13 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f() {\n" checkUninitVar2("void f() {\n"
" char a[10];\n" " char a[10];\n"
" if (a[0] = x){}\n" " if (a[0] = x){}\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("int foo(int x)\n" checkUninitVar2("int foo(int x)\n"
"{\n" "{\n"
" int i;\n" " int i;\n"
" if (one())\n" " if (one())\n"
@ -768,7 +768,7 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Ticket #2207 - False positive // Ticket #2207 - False positive
checkUninitVar("void foo(int x) {\n" checkUninitVar2("void foo(int x) {\n"
" int a;\n" " int a;\n"
" if (x)\n" " if (x)\n"
" a = 1;\n" " a = 1;\n"
@ -778,7 +778,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("int foo()\n" checkUninitVar2("int foo()\n"
"{\n" "{\n"
" int ret;\n" " int ret;\n"
" if (one())\n" " if (one())\n"
@ -789,7 +789,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("int f(int a)\n" checkUninitVar2("int f(int a)\n"
"{\n" "{\n"
" int ret;\n" " int ret;\n"
" if (a == 1)\n" " if (a == 1)\n"
@ -798,9 +798,9 @@ private:
" XYZ ret = 2;\n" // XYZ may be an unexpanded macro so bailout the checking of "ret". " XYZ ret = 2;\n" // XYZ may be an unexpanded macro so bailout the checking of "ret".
" return ret;\n" " return ret;\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("[test.cpp:8]: (error) Uninitialized variable: ret\n", errout.str());
checkUninitVar("int f(int a, int b)\n" checkUninitVar2("int f(int a, int b)\n"
"{\n" "{\n"
" int x;\n" " int x;\n"
" if (a)\n" " if (a)\n"
@ -813,7 +813,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo(long verbose,bool bFlag)\n" checkUninitVar2("void foo(long verbose,bool bFlag)\n"
"{\n" "{\n"
" double t;\n" " double t;\n"
" if (bFlag)\n" " if (bFlag)\n"
@ -826,7 +826,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("int test(int cond1, int cond2) {\n" checkUninitVar2("int test(int cond1, int cond2) {\n"
" int foo;\n" " int foo;\n"
" if (cond1 || cond2) {\n" " if (cond1 || cond2) {\n"
" if (cond2)\n" " if (cond2)\n"
@ -846,7 +846,7 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: x\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: x\n", errout.str());
checkUninitVar("void foo()\n" checkUninitVar2("void foo()\n"
"{\n" "{\n"
" const char *msgid1, *msgid2;\n" " const char *msgid1, *msgid2;\n"
" int ret = bar(&msgid1);\n" " int ret = bar(&msgid1);\n"
@ -858,7 +858,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo(int a, int b)\n" checkUninitVar2("void foo(int a, int b)\n"
"{\n" "{\n"
" int x; x = (a<b) ? 1 : 0;\n" " int x; x = (a<b) ? 1 : 0;\n"
" int y = y;\n" " int y = y;\n"
@ -866,7 +866,7 @@ private:
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: y\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: y\n", errout.str());
// ; { .. } // ; { .. }
checkUninitVar("int foo()\n" checkUninitVar2("int foo()\n"
"{\n" "{\n"
" int retval;\n" " int retval;\n"
" if (condition) {\n" " if (condition) {\n"
@ -878,7 +878,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n" checkUninitVar2("void foo()\n"
"{\n" "{\n"
" {\n" " {\n"
" for (int i = 0; i < 10; ++i)\n" " for (int i = 0; i < 10; ++i)\n"
@ -900,7 +900,7 @@ private:
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: c1\n" ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: c1\n"
"[test.cpp:4]: (error) Uninitialized variable: c2\n", errout.str()); "[test.cpp:4]: (error) Uninitialized variable: c2\n", errout.str());
checkUninitVar("void f(char *c1, char *c2)\n" checkUninitVar2("void f(char *c1, char *c2)\n"
"{\n" "{\n"
" if(strcoll(c1,c2))\n" " if(strcoll(c1,c2))\n"
" {\n" " {\n"
@ -908,14 +908,14 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n" checkUninitVar2("void f()\n"
"{\n" "{\n"
" char *c1;\n" " char *c1;\n"
" c1=strcpy(c1,\"test\");\n" " c1=strcpy(c1,\"test\");\n"
"}"); "}");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: c1\n","", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: c1\n","", errout.str());
checkUninitVar("void f(char *c1)\n" checkUninitVar2("void f(char *c1)\n"
"{\n" "{\n"
" c1=strcpy(c1,\"test\");\n" " c1=strcpy(c1,\"test\");\n"
"}"); "}");
@ -927,7 +927,7 @@ private:
// handling for/while loops.. // handling for/while loops..
void uninitvar_loops() { void uninitvar_loops() {
// for.. // for..
checkUninitVar("void f()\n" checkUninitVar2("void f()\n"
"{\n" "{\n"
" for (int i = 0; i < 4; ++i) {\n" " for (int i = 0; i < 4; ++i) {\n"
" int a;\n" " int a;\n"
@ -936,7 +936,7 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: a\n", errout.str()); ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: a\n", errout.str());
checkUninitVar("void f() {\n" checkUninitVar2("void f() {\n"
" int k;\n" " int k;\n"
" for (int i = 0; i < 4; ++i) {\n" " for (int i = 0; i < 4; ++i) {\n"
" k = k + 2;\n" " k = k + 2;\n"
@ -944,7 +944,7 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: k\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: k\n", errout.str());
checkUninitVar("void f() {\n" checkUninitVar2("void f() {\n"
" gchar sel[10];\n" " gchar sel[10];\n"
" for (int i = 0; i < 4; ++i) {\n" " for (int i = 0; i < 4; ++i) {\n"
" int sz = sizeof(sel);\n" " int sz = sizeof(sel);\n"
@ -952,7 +952,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("enum ABCD { A, B, C, D };\n" checkUninitVar2("enum ABCD { A, B, C, D };\n"
"\n" "\n"
"static void f(char *str ) {\n" "static void f(char *str ) {\n"
" enum ABCD i;\n" " enum ABCD i;\n"
@ -962,7 +962,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void x() {\n" checkUninitVar2("void x() {\n"
" do {\n" " do {\n"
" Token * tok;\n" " Token * tok;\n"
" for (tok = a; tok; tok = tok->next())\n" " for (tok = a; tok; tok = tok->next())\n"
@ -982,7 +982,7 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: i\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: i\n", errout.str());
checkUninitVar("void f(int i)\n" checkUninitVar2("void f(int i)\n"
"{\n" "{\n"
" int a;\n" " int a;\n"
" while (i < 10)\n" " while (i < 10)\n"
@ -992,7 +992,7 @@ private:
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: a\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: a\n", errout.str());
// Ticket #2226: C++0x loop // Ticket #2226: C++0x loop
checkUninitVar("void f() {\n" checkUninitVar2("void f() {\n"
" container c;\n" " container c;\n"
" for (iterator it : c) {\n" " for (iterator it : c) {\n"
" }\n" " }\n"
@ -1000,7 +1000,7 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Ticket #2345: False positive in sub-condition in if inside a loop // Ticket #2345: False positive in sub-condition in if inside a loop
checkUninitVar("void f(int x) {\n" checkUninitVar2("void f(int x) {\n"
" const PoolItem* pItem;\n" " const PoolItem* pItem;\n"
" while (x > 0) {\n" " while (x > 0) {\n"
" if (GetItem(&pItem) && (*pItem != rPool))\n" " if (GetItem(&pItem) && (*pItem != rPool))\n"
@ -1036,7 +1036,7 @@ private:
ASSERT_EQUALS("[test.cpp:11]: (error) Uninitialized variable: x\n", errout.str()); ASSERT_EQUALS("[test.cpp:11]: (error) Uninitialized variable: x\n", errout.str());
// Ticket #2796 // Ticket #2796
checkUninitVar("void foo() {\n" checkUninitVar2("void foo() {\n"
" while (true) {\n" " while (true) {\n"
" int x;\n" " int x;\n"
" if (y) x = 0;\n" " if (y) x = 0;\n"
@ -1047,7 +1047,7 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Assignment in for. Ticket #3287 // Assignment in for. Ticket #3287
checkUninitVar("int foo(char* in, bool b) {\n" checkUninitVar2("int foo(char* in, bool b) {\n"
" char* c;\n" " char* c;\n"
" if (b) for (c = in; *c == 0; ++c) {}\n" " if (b) for (c = in; *c == 0; ++c) {}\n"
" else c = in + strlen(in) - 1;\n" " else c = in + strlen(in) - 1;\n"
@ -1069,10 +1069,10 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: c\n", errout.str()); ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: c\n", errout.str());
checkUninitVar("char * f()\n" checkUninitVar2("char * f()\n"
"{\n" "{\n"
" static char ret[200];\n" " static char ret[200];\n"
" memset(ret, 0, sizeof(ret));\n" " memset(ret, 0, 200);\n"
" switch (x)\n" " switch (x)\n"
" {\n" " {\n"
" case 1: return ret;\n" " case 1: return ret;\n"
@ -1082,10 +1082,9 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("int foo(const int iVar, unsigned int slot, unsigned int pin)\n" checkUninitVar2("int foo(const int iVar, unsigned int slot, unsigned int pin)\n"
"{\n" "{\n"
" int i;\n" " int i;\n"
"\n"
" if (iVar == 0)\n" " if (iVar == 0)\n"
" {\n" " {\n"
" switch (slot)\n" " switch (slot)\n"
@ -1122,7 +1121,7 @@ private:
"}"); "}");
// #1855 - switch(foo(&x)) // #1855 - switch(foo(&x))
checkUninitVar("int a()\n" checkUninitVar2("int a()\n"
"{\n" "{\n"
" int x;\n" " int x;\n"
" switch (foo(&x))\n" " switch (foo(&x))\n"
@ -1179,34 +1178,34 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n" checkUninitVar2("void f()\n"
"{\n" "{\n"
" char a, b[10];\n" " char a, b[10];\n"
" a = b[0] = 0;\n" " a = b[0] = 0;\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n" checkUninitVar2("void f()\n"
"{\n" "{\n"
" char a[10], b[10];\n" " char a[10], b[10];\n"
" a[0] = b[0] = 0;\n" " a[0] = b[0] = 0;\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n" checkUninitVar2("void f()\n"
"{\n" "{\n"
" char a[10], *p;\n" " char a[10], *p;\n"
" *(p = a) = 0;\n" " *(p = a) = 0;\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f() {\n" checkUninitVar2("void f() {\n"
" char a[10], *p;\n" " char a[10], *p;\n"
" p = &(a[10]);\n" " p = &(a[10]);\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n" checkUninitVar2("void f()\n"
"{\n" "{\n"
" char c[50] = \"\";\n" " char c[50] = \"\";\n"
" strcat(c, \"test\");\n" " strcat(c, \"test\");\n"
@ -1243,7 +1242,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n" checkUninitVar2("void foo()\n"
"{\n" "{\n"
" int a[2];\n" " int a[2];\n"
" init(a - 1);\n" " init(a - 1);\n"
@ -1251,7 +1250,7 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n" checkUninitVar2("void foo()\n"
"{\n" "{\n"
" Fred a[2];\n" " Fred a[2];\n"
" Fred b = a[0];\n" " Fred b = a[0];\n"
@ -1259,7 +1258,7 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Ticket #2320 // Ticket #2320
checkUninitVar("void foo() {\n" checkUninitVar2("void foo() {\n"
" char a[2];\n" " char a[2];\n"
" char *b = (a+2) & 7;\n" " char *b = (a+2) & 7;\n"
"}"); "}");
@ -1271,27 +1270,27 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout.str());
checkUninitVar("void f() {\n" // Ticket #5108 (fp) checkUninitVar2("void f() {\n" // Ticket #5108 (fp)
" const char *a;\n" " const char *a;\n"
" printf(\"%s\", a=\"abc\");\n" " printf(\"%s\", a=\"abc\");\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f() {\n" // Ticket #3497 checkUninitVar2("void f() {\n" // Ticket #3497
" char header[1];\n" " char header[1];\n"
" *((unsigned char*)(header)) = 0xff;\n" " *((unsigned char*)(header)) = 0xff;\n"
" return header[0];\n" " return header[0];\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f() {\n" // Ticket #3497 checkUninitVar2("void f() {\n" // Ticket #3497
" char header[1];\n" " char header[1];\n"
" *((unsigned char*)((unsigned char *)(header))) = 0xff;\n" " *((unsigned char*)((unsigned char *)(header))) = 0xff;\n"
" return header[0];\n" " return header[0];\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f() {\n" checkUninitVar2("void f() {\n"
" ABC abc;\n" " ABC abc;\n"
" int a[1];\n" " int a[1];\n"
"\n" "\n"
@ -1311,13 +1310,13 @@ private:
ASSERT_EQUALS("[test.cpp:4]: (error) Memory is allocated but not initialized: buffer\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Memory is allocated but not initialized: buffer\n", errout.str());
// #3845 // #3845
checkUninitVar("int foo() {\n" checkUninitVar2("int foo() {\n"
" int a[1] = {5};\n" " int a[1] = {5};\n"
" return a[0];\n" " return a[0];\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("int foo() {\n" checkUninitVar2("int foo() {\n"
" int a[2][2] = {{3,4}, {5,6}};\n" " int a[2][2] = {{3,4}, {5,6}};\n"
" return a[0][1];\n" " return a[0][1];\n"
"}"); "}");
@ -1329,14 +1328,14 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout.str());
checkUninitVar("int foo() {\n" checkUninitVar2("int foo() {\n"
" int a[2][2];\n" " int a[2][2];\n"
" return a[0][1];\n" " return a[0][1];\n"
"}"); "}");
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", "", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", "", errout.str());
// # 4740 // # 4740
checkUninitVar("void f() {\n" checkUninitVar2("void f() {\n"
" int *a[2][19];\n" " int *a[2][19];\n"
" int **b = a[0];\n" " int **b = a[0];\n"
"}"); "}");
@ -2081,6 +2080,9 @@ private:
// Tokenize.. // Tokenize..
Settings settings1(settings); Settings settings1(settings);
settings1.inconclusive = true;
settings1.standards.posix = true;
settings1.experimental = true;
settings1.debugwarnings = debugwarnings; settings1.debugwarnings = debugwarnings;
Tokenizer tokenizer(&settings1, this); Tokenizer tokenizer(&settings1, this);
std::istringstream istr(code); std::istringstream istr(code);
@ -3142,7 +3144,10 @@ private:
" foo(123, &abc);\n" " foo(123, &abc);\n"
" return abc.b;\n" " return abc.b;\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized struct member: abc.b\n", errout.str()); ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized struct member: abc.a\n"
"[test.cpp:5]: (error) Uninitialized struct member: abc.b\n"
"[test.cpp:6]: (error) Uninitialized struct member: abc.b\n"
"[test.cpp:5]: (error) Uninitialized struct member: abc.c\n", errout.str());
// return // return
checkUninitVar2("struct AB { int a; int b; };\n" checkUninitVar2("struct AB { int a; int b; };\n"