From 218464df8997604eb8445ebaa4424ab4aeecc51e Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Mon, 14 Feb 2011 19:50:13 -0500 Subject: [PATCH] fix #2580 (false postive with Unused private function) --- lib/symboldatabase.cpp | 9 ++++----- test/testunusedprivfunc.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index d29cc5a52..05a0aa0a5 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -906,12 +906,14 @@ const Token *SymbolDatabase::initBaseInfo(Scope *scope, const Token *tok) base.name += tok2->str(); base.scope = 0; - // don't add unhandled templates + // add unhandled templates if (tok2->next()->str() == "<") { int level1 = 1; while (tok2->next()) { + base.name += tok2->next()->str(); + if (tok2->next()->str() == ">") { level1--; @@ -926,10 +928,7 @@ const Token *SymbolDatabase::initBaseInfo(Scope *scope, const Token *tok) } // save pattern for base class name - else - { - scope->derivedFrom.push_back(base); - } + scope->derivedFrom.push_back(base); } tok2 = tok2->next(); } diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index c9358aae8..272df269f 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -67,6 +67,7 @@ private: TEST_CASE(testDoesNotIdentifyMethodAsLastFunctionArgument); TEST_CASE(multiFile); + TEST_CASE(unknownBaseTemplate); // ticket #2580 } @@ -571,6 +572,20 @@ private: ASSERT_EQUALS("", errout.str()); } + + void unknownBaseTemplate() // ticket #2580 + { + check("class Bla : public Base2 {\n" + "public:\n" + " Bla() {}\n" + "private:\n" + " virtual void F() const;\n" + "};\n" + "void Bla::F() const { }"); + + ASSERT_EQUALS("", errout.str()); + } + }; REGISTER_TEST(TestUnusedPrivateFunction)