File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1173,7 +1173,12 @@ void CheckClass::privateFunctions()
11731173 {
11741174 // Final check; check if the function pointer is used somewhere..
11751175 const std::string _pattern (" return|(|)|,|= " + FuncList.front ()->str ());
1176- if (!Token::findmatch (_tokenizer->tokens (), _pattern.c_str ()))
1176+
1177+ // or if the function address is used somewhere...
1178+ // eg. sigc::mem_fun(this, &className::classFunction)
1179+ const std::string _pattern2 (" & " + classname + " :: " + FuncList.front ()->str ());
1180+ if (!Token::findmatch (_tokenizer->tokens (), _pattern.c_str ()) &&
1181+ !Token::findmatch (_tokenizer->tokens (), _pattern2.c_str ()))
11771182 {
11781183 unusedPrivateFunctionError (FuncList.front (), classname, FuncList.front ()->str ());
11791184 }
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class TestUnusedPrivateFunction : public TestFixture
4343 // [ 2236547 ] False positive --style unused function, called via pointer
4444 TEST_CASE (func_pointer1);
4545 TEST_CASE (func_pointer2);
46+ TEST_CASE (func_pointer3);
4647
4748 TEST_CASE (ctor);
4849
@@ -254,6 +255,19 @@ class TestUnusedPrivateFunction : public TestFixture
254255 }
255256
256257
258+ void func_pointer3 ()
259+ {
260+ check (" class c1\n "
261+ " {\n "
262+ " public:\n "
263+ " c1()\n "
264+ " { sigc::mem_fun(this, &c1::f1); }\n "
265+ " \n "
266+ " private:\n "
267+ " void f1() const {}\n "
268+ " };\n " );
269+ ASSERT_EQUALS (" " , errout.str ());
270+ }
257271
258272
259273 void ctor ()
You can’t perform that action at this time.
0 commit comments