Class checking: Minor refactoring when analysing memset on class

This commit is contained in:
Daniel Marjamäki 2010-02-04 20:53:04 +01:00
parent 9943262da0
commit da7e75f69e
2 changed files with 11 additions and 1 deletions

View File

@ -758,7 +758,7 @@ void CheckClass::noMemset()
break;
}
if (Token::Match(tstruct, "std :: %type% < %type% > %var% ;"))
if (Token::Match(tstruct, "std :: %type% < %type% *| > %var% ;"))
{
memsetStructError(tok, tok->str(), tstruct->strAt(2));
break;

View File

@ -1492,6 +1492,16 @@ private:
" memset(a, 0, sizeof(A));\n"
"}");
ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str());
checkNoMemset("struct A\n"
"{ std::vector<int *> ints; }\n"
"\n"
"void f()\n"
"{\n"
" A a;\n"
" memset(a, 0, sizeof(A));\n"
"}");
ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str());
}