File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2111,6 +2111,8 @@ void CheckClass::checkConst()
2111
2111
// don't warn for friend/static/virtual functions
2112
2112
if (func.isFriend () || func.isStatic () || func.hasVirtualSpecifier ())
2113
2113
continue ;
2114
+ if (func.functionPointerUsage )
2115
+ continue ;
2114
2116
2115
2117
// don't suggest const when returning non-const pointer/reference, but still suggest static
2116
2118
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 {
185
185
TEST_CASE (const91);
186
186
TEST_CASE (const92);
187
187
TEST_CASE (const93);
188
+ TEST_CASE (const94);
188
189
189
190
TEST_CASE (const_handleDefaultParameters);
190
191
TEST_CASE (const_passThisToMemberOfOtherClass);
@@ -6691,6 +6692,19 @@ class TestClass : public TestFixture {
6691
6692
errout_str ());
6692
6693
}
6693
6694
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
+
6694
6708
void const_handleDefaultParameters () {
6695
6709
checkConst (" struct Foo {\n "
6696
6710
" void foo1(int i, int j = 0) {\n "
You can’t perform that action at this time.
0 commit comments