memory leaks: don't write errors for static member variables

This commit is contained in:
Daniel Marjamäki 2009-10-06 18:25:00 +02:00
parent c3d56c1d13
commit 36fb24b1a5
2 changed files with 25 additions and 0 deletions

View File

@ -2058,6 +2058,12 @@ void CheckMemoryLeakInClass::parseClass(const Token *tok1, std::vector<const cha
if (indentlevel > 0)
continue;
// skip static variables..
if (Token::Match(tok, "static %type% * %var% ;"))
{
tok = tok->tokAt(4);
}
// Declaring subclass.. recursive checking
if (Token::Match(tok, "class %var% [{:]"))
{

View File

@ -2410,6 +2410,8 @@ private:
TEST_CASE(class10);
TEST_CASE(class11);
TEST_CASE(staticvar);
TEST_CASE(use);
TEST_CASE(free_member_in_sub_func);
@ -2628,6 +2630,23 @@ private:
}
void staticvar()
{
check("class A\n"
"{\n"
"private:\n"
" static int * p;\n"
"public:"
" A()\n"
" {\n"
" if (!p)\n"
" p = new int[100];\n"
" }\n"
"};\n", true);
ASSERT_EQUALS("", errout.str());
}
void use()
{
check("class A\n"