diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 2f06d495c..78d7fbe48 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -206,7 +206,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi while (Token::Match(funcname, "%name% :: %name%")) funcname = funcname->tokAt(2); - if (!Token::Match(funcname, "%name% [(),;]:}]")) + if (!Token::Match(funcname, "%name% [(),;]:}>]")) continue; } diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index 28b12ee85..75b4c3d74 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -40,6 +40,7 @@ private: TEST_CASE(return1); TEST_CASE(return2); TEST_CASE(callback1); + TEST_CASE(callback2); TEST_CASE(else1); TEST_CASE(functionpointer); TEST_CASE(template1); @@ -119,6 +120,19 @@ private: ASSERT_EQUALS("", errout.str()); } + void callback2() { // #8677 + check("class C {\n" + "public:\n" + " void callback();\n" + " void start();\n" + "};\n" + "\n" + "void C::callback() {}\n" // <- not unused + "\n" + "void C::start() { ev.set(this); }"); + ASSERT_EQUALS("[test.cpp:9]: (style) The function 'start' is never used.\n", errout.str()); + } + void else1() { check("void f1()\n" "{\n"