Fixed ticket #358 (Local typedef flagged as uninitialized member)

http://apps.sourceforge.net/trac/cppcheck/ticket/358
This commit is contained in:
Slava Semushin 2009-06-05 07:34:12 +07:00
parent 9b5350e369
commit 6745d9b8ef
2 changed files with 17 additions and 0 deletions

View File

@ -82,6 +82,10 @@ struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1,
if (next->str() == "static")
continue;
// Type definitions shall be ignored..
if (next->str() == "typedef")
continue;
// Is it a variable declaration?
if (Token::Match(next, "%type% %var% ;"))
{

View File

@ -45,6 +45,7 @@ private:
TEST_CASE(uninitVar1);
TEST_CASE(uninitVarEnum);
TEST_CASE(uninitVarStream);
TEST_CASE(uninitVarTypedef);
TEST_CASE(privateCtor1); // If constructor is private..
TEST_CASE(privateCtor2); // If constructor is private..
TEST_CASE(function); // Function is not variable
@ -225,6 +226,18 @@ private:
ASSERT_EQUALS(std::string(""), errout.str());
}
void uninitVarTypedef()
{
checkUninitVar("class Foo\n"
"{\n"
"public:\n"
" typedef int * pointer;\n"
" Foo() : a(0) {}\n"
" pointer a;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void privateCtor1()
{