Fixed #6674 (false positive 'unusedPrivateFunction' - calling virtual function in subclass)

This commit is contained in:
Daniel Marjamäki 2016-05-21 20:07:35 +02:00
parent c23c1f245c
commit b7b92b2140
2 changed files with 21 additions and 1 deletions

View File

@ -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;
}

View File

@ -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() {