From b7b92b21405bcb96f1b2d6e935091ea8fd01ec99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 21 May 2016 20:07:35 +0200 Subject: [PATCH] Fixed #6674 (false positive 'unusedPrivateFunction' - calling virtual function in subclass) --- lib/symboldatabase.cpp | 4 +++- test/testunusedprivfunc.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 210abbb91..a10c737f7 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2789,7 +2789,9 @@ bool Function::isImplicitlyVirtual_rec(const ::Type* baseType, bool& safe) const // check for matching return parameters while (temp1->str() != "virtual") { - if (temp1->str() != temp2->str()) { + if (temp1->str() != temp2->str() && + !(temp1->str() == derivedFromType->name() && + temp2->str() == baseType->name())) { returnMatch = false; break; } diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index ff63d565f..c44aaf5fd 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -481,6 +481,24 @@ private: " void func() {}\n" "};"); ASSERT_EQUALS("", errout.str()); + + check("class Base {\n" + "public:\n" + " void dostuff() {\n" + " f();\n" + " }\n" + "\n" + "private:\n" + " virtual Base* f() = 0;\n" + "};\n" + "\n" + "class Derived : public Base {\n" + "private:\n" + " Derived* f() {\n" + " return 0;\n" + " }\n" + "};"); + ASSERT_EQUALS("", errout.str()); } void friendClass() {