Fixed #4490 (False positive: unused function (function pointer is taken in global scope))

This commit is contained in:
Daniel Marjamäki 2013-01-16 16:52:57 +01:00
parent 78f3c5f772
commit 0fb2d309a6
2 changed files with 5 additions and 3 deletions

View File

@ -93,9 +93,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
const Token *scopeEnd = NULL;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
if (scopeEnd == NULL) {
if (tok->str() != ")")
continue;
if (!Token::Match(tok, ") const| {"))
if (!Token::Match(tok, ")|= const| {"))
continue;
scopeEnd = tok;
while (scopeEnd->str() != "{")

View File

@ -264,6 +264,10 @@ private:
check("void f();\n"
"void f() {}");
ASSERT_EQUALS("[test.cpp:2]: (style) The function 'f' is never used.\n", errout.str());
check("void f(void) {}\n"
"void (*list[])(void) = {f}");
ASSERT_EQUALS("", errout.str());
}
};