Skip to content

Commit

Permalink
Fix #13382 FP functionStatic with forward-declared base class (danmar…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Dec 6, 2024
1 parent 469c5e7 commit 741fb09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
for (const Type::BaseInfo & i : scope->definedType->derivedFrom) {
// find the base class
const Type *derivedFrom = i.type;
if (!derivedFrom)
if (!derivedFrom || !derivedFrom->classScope)
foundAllBaseClasses = false;

// find the function in the base class
Expand Down
13 changes: 11 additions & 2 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6715,13 +6715,22 @@ class TestClass : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void const96() { // #13282
checkConst("struct S : B {\n"
void const96() {
checkConst("struct S : B {\n" // #13282
" bool f() { return b; }\n"
" bool g() override { return b; }\n"
" bool b;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Either there is a missing 'override', or the member function 'S::f' can be const.\n", errout_str());

checkConst("struct B;\n" // #13382
"struct S : B {\n"
" void f();\n"
"};\n"
"void S::f() {\n"
" B::g(0);\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void const97() { // #13301
Expand Down

0 comments on commit 741fb09

Please sign in to comment.