unused private function: fixed false positive (ticket: 129)

This commit is contained in:
Daniel Marjamäki 2009-03-02 17:16:02 +00:00
parent cc6cec091a
commit 86050cccdb
2 changed files with 18 additions and 1 deletions

View File

@ -545,7 +545,7 @@ void CheckClass::privateFunctions()
// Check member class functions to see what functions are used.. // Check member class functions to see what functions are used..
if ((inclass && indent_level == 1 && Token::Match(ftok, ") const| {")) || if ((inclass && indent_level == 1 && Token::Match(ftok, ") const| {")) ||
(Token::Match(ftok, (classname + " :: %var% (").c_str()))) (Token::Match(ftok, (classname + " :: ~| %var% (").c_str())))
{ {
while (ftok && ftok->str() != ")") while (ftok && ftok->str() != ")")
ftok = ftok->next(); ftok = ftok->next();

View File

@ -37,6 +37,7 @@ private:
{ {
TEST_CASE(test1); TEST_CASE(test1);
TEST_CASE(test2); TEST_CASE(test2);
TEST_CASE(test3);
// [ 2236547 ] False positive --style unused function, called via pointer // [ 2236547 ] False positive --style unused function, called via pointer
TEST_CASE(func_pointer); TEST_CASE(func_pointer);
@ -101,6 +102,22 @@ private:
} }
void test3()
{
check("class A {\n"
"public:\n"
" A() { }\n"
" ~A();\n"
"private:\n"
" void B() { }\n"
"};\n"
"\n"
"A::~A()\n"
"{ B(); }\n");
ASSERT_EQUALS(std::string(""), errout.str());
}