Skip to content

Commit df927d5

Browse files
Fix #14425 FP functionStatic: function call on this with unknown base class (danmar#8151)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 73b2ad6 commit df927d5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/checkclass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,8 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
23532353
bool CheckClass::isMemberFunc(const Scope *scope, const Token *tok)
23542354
{
23552355
if (!tok->function()) {
2356+
if (Token::simpleMatch(tok->astParent(), ".") && Token::simpleMatch(tok->astParent()->astOperand1(), "this"))
2357+
return true;
23562358
for (const Function &func : scope->functionList) {
23572359
if (func.name() == tok->str()) {
23582360
const Token* tok2 = tok->tokAt(2);

test/testclass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6827,6 +6827,11 @@ class TestClass : public TestFixture {
68276827
ASSERT_EQUALS("[test.cpp:5:10]: (style) Either there is a missing 'override', or the member function 'S::g' can be static. [functionStatic]\n"
68286828
"[test.cpp:6:10]: (style) Either there is a missing 'override', or the member function 'S::h' can be static. [functionStatic]\n",
68296829
errout_str());
6830+
6831+
checkConst("struct S : U {\n" // #14425
6832+
" void f() { this->g(); }\n"
6833+
"};\n");
6834+
ASSERT_EQUALS("", errout_str());
68306835
}
68316836

68326837
void const97() { // #13301

0 commit comments

Comments
 (0)