private functions: don't report false positives when using initialization lists (#254)

This commit is contained in:
Daniel Marjamäki 2009-04-14 21:46:13 +02:00
parent 7750f327ff
commit 3c3a56bfca
2 changed files with 23 additions and 2 deletions

View File

@ -436,7 +436,10 @@ void CheckClass::privateFunctions()
if (Token::Match(tok, "typedef %type% ("))
tok = tok->tokAt(2);
if (Token::Match(tok, "%var% (") &&
else if (Token::Match(tok, "[:,] %var% ("))
tok = tok->tokAt(2);
else if (Token::Match(tok, "%var% (") &&
!Token::Match(tok, classname.c_str()))
{
FuncList.push_back(tok);

View File

@ -42,6 +42,8 @@ private:
// [ 2236547 ] False positive --style unused function, called via pointer
TEST_CASE(func_pointer);
TEST_CASE(ctor);
}
@ -166,6 +168,22 @@ private:
}
void ctor()
{
check("class PrivateCtor\n"
"{\n"
"private:\n"
" PrivateCtor(int threadNum) :\n"
" numOfThreads(threadNum)\n"
" {\n"
" }\n"
"\n"
" int numOfThreads;\n"
"};\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
};