Fixed #1195 (Uninitialized member variable not detected 'std::vector<int> *ints;')

This commit is contained in:
Robert Reif 2010-10-27 19:28:15 +02:00 committed by Daniel Marjamäki
parent 5a8f490f07
commit b6aca47e11
2 changed files with 16 additions and 1 deletions

View File

@ -722,7 +722,6 @@ void CheckClass::SpaceInfo::getVarList()
else if (Token::Match(next, "%type% :: %type% <") ||
Token::Match(next, "%type% <"))
{
isClass = true;
// find matching ">"
int level = 0;
for (; next; next = next->next())
@ -737,7 +736,10 @@ void CheckClass::SpaceInfo::getVarList()
}
}
if (next && Token::Match(next, "> %var% ;"))
{
isClass = true;
vartok = next->tokAt(1);
}
else if (next && Token::Match(next, "> * %var% ;"))
vartok = next->tokAt(2);
}

View File

@ -56,6 +56,7 @@ private:
TEST_CASE(uninitVar10); // ticket #1993
TEST_CASE(uninitVar11);
TEST_CASE(uninitVar12); // ticket #2078
TEST_CASE(uninitVar13); // ticket #1195
TEST_CASE(uninitVarEnum);
TEST_CASE(uninitVarStream);
TEST_CASE(uninitVarTypedef);
@ -1700,6 +1701,18 @@ private:
"[test.cpp:4]: (warning) Member variable not initialized in the constructor 'Point::y'\n", errout.str());
}
void uninitVar13() // ticket #1195
{
checkUninitVar("class A {\n"
"private:\n"
" std::vector<int> *ints;\n"
"public:\n"
" A()\n"
" {}\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5]: (warning) Member variable not initialized in the constructor 'A::ints'\n", errout.str());
}
void uninitVarArray1()
{
checkUninitVar("class John\n"