Fixed #3875 (Static member method called with class name is considered unused)

This commit is contained in:
Daniel Marjamäki 2012-06-14 22:04:21 +02:00
parent 5174f7ff5e
commit f967142436
2 changed files with 20 additions and 2 deletions

View File

@ -107,8 +107,15 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
else if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]")) else if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]"))
funcname = tok->next(); funcname = tok->next();
else if (Token::Match(tok, "[=(,] & %var% :: %var% [,);]")) else if (Token::Match(tok, "[=(,] &| %var% :: %var%")) {
funcname = tok->tokAt(4); funcname = tok->next();
if (funcname->str() == "&")
funcname = funcname->next();
while (Token::Match(funcname,"%var% :: %var%"))
funcname = funcname->tokAt(2);
if (!Token::Match(funcname, "%var% [,);]"))
continue;
}
else else
continue; continue;

View File

@ -135,6 +135,17 @@ private:
" return 0\n" " return 0\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("namespace abc {\n" // #3875
"void foo() { }\n"
"};\n"
"\n"
"int main()\n"
"{\n"
" f(abc::foo);\n"
" return 0\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void template1() { void template1() {