diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index e0333b71c..69f603ed5 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -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::iterator i; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f8d141b6b..2378769a5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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(";"); } } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 29cedb757..9bfa20b59 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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)); } diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index 8d0fd075a..0b099189c 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -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)