Fixed #2459 (False positive with unused private function and friend)

This commit is contained in:
Daniel Marjamäki 2011-01-22 13:00:03 +01:00
parent 5c88129f01
commit 9551332321
2 changed files with 18 additions and 0 deletions

View File

@ -583,6 +583,11 @@ void CheckClass::privateFunctions()
if (Token::findmatch(_tokenizer->tokens(), "; __property ;"))
return;
// skip checking if there are friends
// Todo: check if each class has friends
if (Token::findmatch(_tokenizer->tokens(), "friend"))
return;
// #2407 calls from operator() is not detected
// TODO: Don't bailout. Detect the call.
if (Token::findmatch(_tokenizer->tokens(), "operator ( )"))

View File

@ -53,6 +53,8 @@ private:
TEST_CASE(derivedClass); // skip warning for derived classes. It might be a virtual function.
TEST_CASE(friendClass);
TEST_CASE(borland); // skip FP when using __property
// No false positives when there are "unused" templates that are removed in the simplified token list
@ -387,6 +389,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void friendClass()
{
// ticket #2459 - friend class
check("class Foo {\n"
"private:\n"
" friend Bar;\n"
" void f() { }\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void borland()
{
// ticket #2034 - Borland C++ __property