Uninitialized variables: Added TODO test case (while)

This commit is contained in:
Daniel Marjamki 2013-01-20 18:40:24 +01:00
parent 76534ccd1b
commit c478a3214f
1 changed files with 16 additions and 0 deletions

View File

@ -60,6 +60,7 @@ private:
TEST_CASE(uninitvar2_func); // function calls
TEST_CASE(uninitvar2_value); // value flow
TEST_CASE(uninitvar2_structmembers); // struct members
TEST_CASE(uninitvar2_while);
}
void checkUninitVar(const char code[], const char filename[] = "test.cpp") {
@ -2670,6 +2671,21 @@ private:
"}\n", "test.c", true);
ASSERT_EQUALS("[test.c:9]: (error) Uninitialized struct member: fred.b\n", errout.str());
}
void uninitvar2_while() {
checkUninitVar2("int f(void) {\n"
" int x;\n"
" while (a()) {\n" // <- condition must always be true or there will be problem
" if (b()) {\n"
" x = 1;\n"
" break;"
" }\n"
" }\n"
" return x;\n"
"}\n", "test.c", true);
TODO_ASSERT_EQUALS("error", "", errout.str());
}
};
REGISTER_TEST(TestUninitVar)