unused private function: better handling of initialization lists in constructors

This commit is contained in:
Daniel Marjamäki 2009-03-02 20:40:24 +00:00
parent 71a79a4ce6
commit 37c889ab30
2 changed files with 22 additions and 0 deletions

View File

@ -551,6 +551,11 @@ void CheckClass::privateFunctions()
ftok = ftok->next(); ftok = ftok->next();
if (!ftok) if (!ftok)
break; break;
if (Token::Match(ftok, ") : %var% ("))
{
while (!Token::Match(ftok->next(), "[{};]"))
ftok = ftok->next();
}
if (!Token::Match(ftok, ") const| {")) if (!Token::Match(ftok, ") const| {"))
continue; continue;

View File

@ -38,6 +38,7 @@ private:
TEST_CASE(test1); TEST_CASE(test1);
TEST_CASE(test2); TEST_CASE(test2);
TEST_CASE(test3); TEST_CASE(test3);
TEST_CASE(test4);
// [ 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);
@ -118,6 +119,22 @@ private:
} }
void test4()
{
check("class A {\n"
"public:\n"
" A();\n"
"private:\n"
" bool _owner;\n"
" void b() { }\n"
"};\n"
"\n"
"A::A() : _owner(false)\n"
"{ b(); }\n");
ASSERT_EQUALS(std::string(""), errout.str());
}