diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 11951411f8f..d8f7d16fbaf 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2287,6 +2287,9 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const } else if (tok->str() == "]") { tok = tok->link()->previous(); again = true; + } else if (Token::Match(tok, "%name% ::")) { + tok = tok->tokAt(2); + again = true; } } while (again); diff --git a/test/testclass.cpp b/test/testclass.cpp index 46c61d41c37..ffcf5b0f868 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6816,6 +6816,17 @@ class TestClass : public TestFixture { ASSERT_EQUALS("[test.cpp:4:7]: (style) Either there is a missing 'override', or the member function 'S::g' can be static. [functionStatic]\n" "[test.cpp:7:9]: (style) Either there is a missing 'override', or the member function 'S::h' can be static. [functionStatic]\n", errout_str()); + + checkConst("namespace N {\n" // #14391 + " void f();\n" + "}\n" + "struct S : U {\n" + " void g() { N::f(); }\n" + " void h() { ::N::f(); }\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:5:10]: (style) Either there is a missing 'override', or the member function 'S::g' can be static. [functionStatic]\n" + "[test.cpp:6:10]: (style) Either there is a missing 'override', or the member function 'S::h' can be static. [functionStatic]\n", + errout_str()); } void const97() { // #13301