Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13382 FP functionStatic with forward-declared base class #7078

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading