diff --git a/src/checkfunctionusage.cpp b/src/checkfunctionusage.cpp index 546db0ad8..1020a8505 100644 --- a/src/checkfunctionusage.cpp +++ b/src/checkfunctionusage.cpp @@ -107,6 +107,9 @@ void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer) if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]")) funcname = tok->next(); + if (Token::Match(tok, "[(,] & %var% :: %var% [,)]")) + funcname = tok->tokAt(4); + // funcname ( => Assert that the end paranthesis isn't followed by { if (Token::Match(funcname, "%var% (")) { diff --git a/test/testfunctionusage.cpp b/test/testfunctionusage.cpp index a21734ebd..6e1a605b4 100644 --- a/test/testfunctionusage.cpp +++ b/test/testfunctionusage.cpp @@ -39,6 +39,7 @@ private: TEST_CASE(return1); TEST_CASE(callback1); TEST_CASE(else1); + TEST_CASE(functionpointer); } void check(const char code[]) @@ -98,6 +99,20 @@ private: std::string err(errout.str()); ASSERT_EQUALS(std::string(""), errout.str()); } + + void functionpointer() + { + check("namespace abc {\n" + "void foo() { }\n" + "};\n" + "\n" + "int main()\n" + "{\n" + " f(&abc::foo);\n" + " return 0\n" + "}\n"); + ASSERT_EQUALS(std::string(""), errout.str()); + } }; REGISTER_TEST(TestFunctionUsage)