diff --git a/src/checkclass.cpp b/src/checkclass.cpp index c51e54545..7c5fdca7a 100644 --- a/src/checkclass.cpp +++ b/src/checkclass.cpp @@ -476,7 +476,7 @@ void CheckClass::privateFunctions() // The class implementation must be available.. const std::string classconstructor(classname + " :: " + classname); - if (tok1->fileIndex()>0 && !Token::findmatch(_tokenizer->tokens(), classconstructor.c_str())) + if (!Token::findmatch(_tokenizer->tokens(), classconstructor.c_str())) continue; // Get private functions.. @@ -549,13 +549,13 @@ void CheckClass::privateFunctions() { if (ftok->str() == "{") ++indent_level; - else if (ftok->str() == "}") + if (ftok->str() == "}") { if (indent_level <= 1) break; --indent_level; } - else if (Token::Match(ftok, "%var% (")) + if (Token::Match(ftok->next(), "(")) { // Remove function from FuncList for (std::list::iterator it = FuncList.begin(); it != FuncList.end(); ++it) diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index a96d3c955..10b489f4d 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -36,7 +36,6 @@ private: void run() { TEST_CASE(test1); - TEST_CASE(test2); // [ 2236547 ] False positive --style unused function, called via pointer TEST_CASE(func_pointer); @@ -82,26 +81,6 @@ private: } - void test2() - { - check("class A {\n" - "public:\n" - " A();\n" - "\n" - " void a() const\n" - " { b(); }\n" - "private:\n" - " void b( ) const\n" - " { }\n" - "};\n" - "\n" - "A::A()\n" - "{ }\n"); - ASSERT_EQUALS(std::string(""), errout.str()); - } - - -