Fixed ticket #358 (Local typedef flagged as uninitialized member)
http://apps.sourceforge.net/trac/cppcheck/ticket/358
This commit is contained in:
parent
9b5350e369
commit
6745d9b8ef
|
@ -82,6 +82,10 @@ struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1,
|
||||||
if (next->str() == "static")
|
if (next->str() == "static")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Type definitions shall be ignored..
|
||||||
|
if (next->str() == "typedef")
|
||||||
|
continue;
|
||||||
|
|
||||||
// Is it a variable declaration?
|
// Is it a variable declaration?
|
||||||
if (Token::Match(next, "%type% %var% ;"))
|
if (Token::Match(next, "%type% %var% ;"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,6 +45,7 @@ private:
|
||||||
TEST_CASE(uninitVar1);
|
TEST_CASE(uninitVar1);
|
||||||
TEST_CASE(uninitVarEnum);
|
TEST_CASE(uninitVarEnum);
|
||||||
TEST_CASE(uninitVarStream);
|
TEST_CASE(uninitVarStream);
|
||||||
|
TEST_CASE(uninitVarTypedef);
|
||||||
TEST_CASE(privateCtor1); // If constructor is private..
|
TEST_CASE(privateCtor1); // If constructor is private..
|
||||||
TEST_CASE(privateCtor2); // If constructor is private..
|
TEST_CASE(privateCtor2); // If constructor is private..
|
||||||
TEST_CASE(function); // Function is not variable
|
TEST_CASE(function); // Function is not variable
|
||||||
|
@ -225,6 +226,18 @@ private:
|
||||||
ASSERT_EQUALS(std::string(""), errout.str());
|
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()
|
void privateCtor1()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue