From 86050cccdb5dce928fa6d716d4df84a5ef6360b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 2 Mar 2009 17:16:02 +0000 Subject: [PATCH] unused private function: fixed false positive (ticket: 129) --- src/checkclass.cpp | 2 +- test/testunusedprivfunc.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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()); + } + +