From 26a9a1b571a20140fdbb6c9034d7551eea3f1756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 9 Apr 2012 11:19:19 +0200 Subject: [PATCH] Fixed #3661 (False positive: unusedPrivateFunction) --- lib/symboldatabase.cpp | 2 +- test/testunusedprivfunc.cpp | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index b6564de67..2050ab94c 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -192,7 +192,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti scope->access = Private; else if (tok->str() == "protected:") scope->access = Protected; - else if (tok->str() == "public:") + else if (tok->str() == "public:" || tok->str() == "__published:") scope->access = Public; else if (Token::Match(tok, "public|protected|private %var% :")) { if (tok->str() == "private") diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index 033775bf1..ed1401176 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -56,7 +56,8 @@ private: TEST_CASE(friendClass); - TEST_CASE(borland); // skip FP when using __property + TEST_CASE(borland1); // skip FP when using __property + TEST_CASE(borland2); // skip FP when using __published // No false positives when there are "unused" templates that are removed in the simplified token list TEST_CASE(template1); @@ -472,7 +473,7 @@ private: ASSERT_EQUALS("[test.cpp:5]: (style) Unused private function 'Foo::f'\n", errout.str()); } - void borland() { + void borland1() { // ticket #2034 - Borland C++ __property check("class Foo {\n" "private:\n" @@ -486,6 +487,19 @@ private: ASSERT_EQUALS("", errout.str()); } + void borland2() { + // ticket #3661 - Borland C++ __published + check("class Foo {\n" + "__published:\n" + " int getx() {\n" + " return 123;\n" + " }\n" + "public:\n" + " Foo() { }\n" + "};"); + ASSERT_EQUALS("", errout.str()); + } + void template1() { // ticket #2067 - Template methods do not "use" private ones check("class A {\n"