Fixed #2034 (false positive: unused private function (Borland C++ __property))
This commit is contained in:
parent
2ab78d819e
commit
3a4cda0f0d
|
@ -1189,6 +1189,10 @@ void CheckClass::privateFunctions()
|
|||
if (!_settings->_checkCodingStyle)
|
||||
return;
|
||||
|
||||
// dont check borland classes with properties..
|
||||
if (Token::findmatch(_tokenizer->tokens(), "; __property ;"))
|
||||
return;
|
||||
|
||||
createSymbolDatabase();
|
||||
|
||||
std::multimap<std::string, SpaceInfo *>::iterator i;
|
||||
|
|
|
@ -8390,6 +8390,11 @@ void Tokenizer::simplifyBorland()
|
|||
Token::eraseTokens(tok2, tok2->link());
|
||||
tok2->deleteThis();
|
||||
tok2->deleteThis();
|
||||
|
||||
// insert "; __property ;"
|
||||
tok2->previous()->insertToken(";");
|
||||
tok2->previous()->insertToken("__property");
|
||||
tok2->previous()->insertToken(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4649,7 +4649,7 @@ private:
|
|||
tokenizeAndStringify("int (__closure *a)();", false));
|
||||
|
||||
// __property
|
||||
ASSERT_EQUALS("class Fred { } ;",
|
||||
ASSERT_EQUALS("class Fred { ; __property ; } ;",
|
||||
tokenizeAndStringify("class Fred { __property int x = { } };", false));
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ private:
|
|||
TEST_CASE(incompleteImplementation);
|
||||
|
||||
TEST_CASE(derivedClass); // skip warning for derived classes. It might be a virtual function.
|
||||
|
||||
TEST_CASE(borland); // skip FP when using __property
|
||||
}
|
||||
|
||||
|
||||
|
@ -374,6 +376,21 @@ private:
|
|||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void borland()
|
||||
{
|
||||
// ticket #2034 - Borland C++ __property
|
||||
check("class Foo {\n"
|
||||
"private:\n"
|
||||
" int getx() {\n"
|
||||
" return 123;\n"
|
||||
" }\n"
|
||||
"public:\n"
|
||||
" Foo() { }\n"
|
||||
" __property int x = {read=getx}\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestUnusedPrivateFunction)
|
||||
|
|
Loading…
Reference in New Issue