File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2111,6 +2111,8 @@ void CheckClass::checkConst()
21112111 // don't warn for friend/static/virtual functions
21122112 if (func.isFriend () || func.isStatic () || func.hasVirtualSpecifier ())
21132113 continue ;
2114+ if (func.functionPointerUsage )
2115+ continue ;
21142116
21152117 // don't suggest const when returning non-const pointer/reference, but still suggest static
21162118 auto isPointerOrReference = [this ](const Token* start, const Token* end) -> bool {
Original file line number Diff line number Diff line change @@ -185,6 +185,7 @@ class TestClass : public TestFixture {
185185 TEST_CASE (const91);
186186 TEST_CASE (const92);
187187 TEST_CASE (const93);
188+ TEST_CASE (const94);
188189
189190 TEST_CASE (const_handleDefaultParameters);
190191 TEST_CASE (const_passThisToMemberOfOtherClass);
@@ -6691,6 +6692,19 @@ class TestClass : public TestFixture {
66916692 errout_str ());
66926693 }
66936694
6695+ void const94 () { // #7459
6696+ checkConst (" class A {\n "
6697+ " public:\n "
6698+ " A() : tickFunction(&A::nop) {}\n "
6699+ " void tick() { (this->*tickFunction)(); }\n "
6700+ " private:\n "
6701+ " typedef void (A::* Fn)();\n "
6702+ " Fn tickFunction;\n "
6703+ " void nop() {}\n "
6704+ " };\n " );
6705+ ASSERT_EQUALS (" " , errout_str ());
6706+ }
6707+
66946708 void const_handleDefaultParameters () {
66956709 checkConst (" struct Foo {\n "
66966710 " void foo1(int i, int j = 0) {\n "
You can’t perform that action at this time.
0 commit comments