Fixed #4787 (False Positive: Unused private function)
This commit is contained in:
parent
5539e9ea0f
commit
d62055277d
|
@ -805,7 +805,7 @@ static bool checkFunctionUsage(const std::string& name, const Scope* scope)
|
|||
if (func->functionScope) {
|
||||
if (Token::Match(func->tokenDef, "%var% (")) {
|
||||
for (const Token *ftok = func->tokenDef->tokAt(2); ftok && ftok->str() != ")"; ftok = ftok->next()) {
|
||||
if (Token::Match(ftok, "= %var% (") && ftok->strAt(1) == name)
|
||||
if (Token::Match(ftok, "= %var% [(,)]") && ftok->strAt(1) == name)
|
||||
return true;
|
||||
if (ftok->str() == "(")
|
||||
ftok = ftok->link();
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
TEST_CASE(func_pointer3);
|
||||
TEST_CASE(func_pointer4); // ticket #2807
|
||||
TEST_CASE(func_pointer5); // ticket #2233
|
||||
TEST_CASE(func_pointer6); // ticket #4787
|
||||
|
||||
TEST_CASE(ctor);
|
||||
TEST_CASE(ctor2);
|
||||
|
@ -314,6 +315,18 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void func_pointer6() { // #4787
|
||||
check("class Test {\n"
|
||||
"private:\n"
|
||||
" static void a(const char* p) { }\n"
|
||||
"public:\n"
|
||||
" void test(void* f = a) {\n"
|
||||
" f(\"test\");\n"
|
||||
" }\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void ctor() {
|
||||
check("class PrivateCtor\n"
|
||||
|
|
Loading…
Reference in New Issue