diff --git a/src/checkclass.cpp b/src/checkclass.cpp index 5f8c9cf4f..2371686c4 100644 --- a/src/checkclass.cpp +++ b/src/checkclass.cpp @@ -545,7 +545,7 @@ void CheckClass::privateFunctions() // Check member class functions to see what functions are used.. if ((inclass && indent_level == 1 && Token::Match(ftok, ") const| {")) || - (Token::Match(ftok, (classname + " :: %var% (").c_str()))) + (Token::Match(ftok, (classname + " :: ~| %var% (").c_str()))) { while (ftok && ftok->str() != ")") ftok = ftok->next(); diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index b060776c5..16e36afee 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -37,6 +37,7 @@ private: { TEST_CASE(test1); TEST_CASE(test2); + TEST_CASE(test3); // [ 2236547 ] False positive --style unused function, called via pointer TEST_CASE(func_pointer); @@ -101,6 +102,22 @@ private: } + void test3() + { + check("class A {\n" + "public:\n" + " A() { }\n" + " ~A();\n" + "private:\n" + " void B() { }\n" + "};\n" + "\n" + "A::~A()\n" + "{ B(); }\n"); + ASSERT_EQUALS(std::string(""), errout.str()); + } + +