Skip to content

Commit 87cc438

Browse files
Fix #14391 FN functionStatic with function in namespace and unknown base class (danmar#8115)
1 parent bf76975 commit 87cc438

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/checkclass.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,9 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
22872287
} else if (tok->str() == "]") {
22882288
tok = tok->link()->previous();
22892289
again = true;
2290+
} else if (Token::Match(tok, "%name% ::")) {
2291+
tok = tok->tokAt(2);
2292+
again = true;
22902293
}
22912294
} while (again);
22922295

test/testclass.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6816,6 +6816,17 @@ class TestClass : public TestFixture {
68166816
ASSERT_EQUALS("[test.cpp:4:7]: (style) Either there is a missing 'override', or the member function 'S::g' can be static. [functionStatic]\n"
68176817
"[test.cpp:7:9]: (style) Either there is a missing 'override', or the member function 'S::h' can be static. [functionStatic]\n",
68186818
errout_str());
6819+
6820+
checkConst("namespace N {\n" // #14391
6821+
" void f();\n"
6822+
"}\n"
6823+
"struct S : U {\n"
6824+
" void g() { N::f(); }\n"
6825+
" void h() { ::N::f(); }\n"
6826+
"};\n");
6827+
ASSERT_EQUALS("[test.cpp:5:10]: (style) Either there is a missing 'override', or the member function 'S::g' can be static. [functionStatic]\n"
6828+
"[test.cpp:6:10]: (style) Either there is a missing 'override', or the member function 'S::h' can be static. [functionStatic]\n",
6829+
errout_str());
68196830
}
68206831

68216832
void const97() { // #13301

0 commit comments

Comments
 (0)