unused private function: better handling of initialization lists in constructors
This commit is contained in:
parent
71a79a4ce6
commit
37c889ab30
|
@ -551,6 +551,11 @@ void CheckClass::privateFunctions()
|
|||
ftok = ftok->next();
|
||||
if (!ftok)
|
||||
break;
|
||||
if (Token::Match(ftok, ") : %var% ("))
|
||||
{
|
||||
while (!Token::Match(ftok->next(), "[{};]"))
|
||||
ftok = ftok->next();
|
||||
}
|
||||
if (!Token::Match(ftok, ") const| {"))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ private:
|
|||
TEST_CASE(test1);
|
||||
TEST_CASE(test2);
|
||||
TEST_CASE(test3);
|
||||
TEST_CASE(test4);
|
||||
|
||||
// [ 2236547 ] False positive --style unused function, called via 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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue