File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -199,6 +199,11 @@ void CheckClass::privateFunctions()
199199 if (Token::findmatch (_tokenizer->tokens (), " ; __property ;" ))
200200 return ;
201201
202+ // #2407 calls from operator() is not detected
203+ // TODO: Don't bailout. Detect the call.
204+ if (Token::findmatch (_tokenizer->tokens (), " operator ( )" ))
205+ return ;
206+
202207 createSymbolDatabase ();
203208
204209 std::list<SymbolDatabase::SpaceInfo *>::iterator i;
Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ class TestUnusedPrivateFunction : public TestFixture
5757
5858 // No false positives when there are "unused" templates that are removed in the simplified token list
5959 TEST_CASE (template1);
60+
61+ // #2407 - FP when called from operator()
62+ TEST_CASE (fp_operator);
6063 }
6164
6265
@@ -414,6 +417,36 @@ class TestUnusedPrivateFunction : public TestFixture
414417 " };\n " );
415418 ASSERT_EQUALS (" " , errout.str ());
416419 }
420+
421+ void fp_operator ()
422+ {
423+ // #2407 - FP when function is called from operator()
424+ check (" class Fred\n "
425+ " {\n "
426+ " public:\n "
427+ " void operator()(int x) {\n "
428+ " startListening();\n "
429+ " }\n "
430+ " \n "
431+ " private:\n "
432+ " void startListening() {\n "
433+ " }\n "
434+ " };\n " );
435+ ASSERT_EQUALS (" " , errout.str ());
436+
437+ check (" class Fred\n "
438+ " {\n "
439+ " public:\n "
440+ " void operator()(int x) {\n "
441+ " }\n "
442+ " \n "
443+ " private:\n "
444+ " void startListening() {\n "
445+ " }\n "
446+ " };\n " );
447+ TODO_ASSERT_EQUALS (" [test.cpp:8]: (style) Unused private function 'Fred::startListening'\n " , errout.str ());
448+ ASSERT_EQUALS (" " , errout.str ());
449+ }
417450};
418451
419452REGISTER_TEST (TestUnusedPrivateFunction)
You can’t perform that action at this time.
0 commit comments