Fixed #4490 (False positive: unused function (function pointer is taken in global scope))
This commit is contained in:
parent
78f3c5f772
commit
0fb2d309a6
|
@ -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() != "{")
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue