Fixed #1966 (False positive: Unused private function (virtual function in base class))

This commit is contained in:
Daniel Marjamäki 2010-08-26 22:05:45 +02:00
parent df87ce9e04
commit 0597c50a47
2 changed files with 16 additions and 1 deletions

View File

@ -1075,7 +1075,7 @@ void CheckClass::privateFunctions()
if (!_settings->_checkCodingStyle)
return;
const char pattern_class[] = "class|struct %var% {|:";
const char pattern_class[] = "class|struct %var% {";
// Locate some class
for (const Token *tok1 = Token::findmatch(_tokenizer->tokens(), pattern_class);

View File

@ -50,6 +50,8 @@ private:
TEST_CASE(classInClass);
TEST_CASE(sameFunctionNames);
TEST_CASE(incompleteImplementation);
TEST_CASE(derivedClass); // skip warning for derived classes. It might be a virtual function.
}
@ -359,6 +361,19 @@ private:
"void A::b() { }\n");
ASSERT_EQUALS("", errout.str());
}
void derivedClass()
{
// skip warning in derived classes in case the function is virtual
check("class derived : public base\n"
"{\n"
"public:\n"
" derived() : base() { }\n"
"private:\n"
" void f();\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestUnusedPrivateFunction)