diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 1954d6377..50b1b303e 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -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() != "{") diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index 27b7811e8..e22d45f77 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -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()); } };