Uninitialized variables: Added TODO test case

This commit is contained in:
Daniel Marjamäki 2011-02-12 12:42:16 +01:00
parent 318f2e8a57
commit ee0f5ff7b3
1 changed files with 23 additions and 0 deletions

View File

@ -46,6 +46,7 @@ private:
TEST_CASE(uninitvar_references); // references
TEST_CASE(uninitvar_strncpy); // strncpy doesn't always 0-terminate
TEST_CASE(uninitvar_func); // analyse functions
TEST_CASE(uninitvar_func2); // usage of 'void a(int *p) { *p = 0; }'
TEST_CASE(uninitvar_typeof); // typeof
}
@ -1420,6 +1421,28 @@ private:
ASSERT_EQUALS("", errout.str());
}
// valid and invalid use of 'void a(int *p) { *p = 0; }'
void uninitvar_func2()
{
const std::string funca("void a(int *p) { *p = 0; }\n");
// ok - initialized pointer
checkUninitVar((funca +
"void b() {\n"
" int buf[10];\n"
" a(buf);\n"
"}\n").c_str());
ASSERT_EQUALS("", errout.str());
// not ok - uninitialized pointer
checkUninitVar((funca +
"void b() {\n"
" int *p;\n"
" a(p);\n"
"}\n").c_str());
TODO_ASSERT_EQUALS("error", "", errout.str());
}
void uninitvar_typeof()
{
checkUninitVar("void f() {\n"