Skip to content

Commit 741fb09

Browse files
Fix #13382 FP functionStatic with forward-declared base class (#7078)
1 parent 469c5e7 commit 741fb09

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/checkclass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
22822282
for (const Type::BaseInfo & i : scope->definedType->derivedFrom) {
22832283
// find the base class
22842284
const Type *derivedFrom = i.type;
2285-
if (!derivedFrom)
2285+
if (!derivedFrom || !derivedFrom->classScope)
22862286
foundAllBaseClasses = false;
22872287

22882288
// find the function in the base class

test/testclass.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -6715,13 +6715,22 @@ class TestClass : public TestFixture {
67156715
ASSERT_EQUALS("", errout_str());
67166716
}
67176717

6718-
void const96() { // #13282
6719-
checkConst("struct S : B {\n"
6718+
void const96() {
6719+
checkConst("struct S : B {\n" // #13282
67206720
" bool f() { return b; }\n"
67216721
" bool g() override { return b; }\n"
67226722
" bool b;\n"
67236723
"};\n");
67246724
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());
6725+
6726+
checkConst("struct B;\n" // #13382
6727+
"struct S : B {\n"
6728+
" void f();\n"
6729+
"};\n"
6730+
"void S::f() {\n"
6731+
" B::g(0);\n"
6732+
"}\n");
6733+
ASSERT_EQUALS("", errout_str());
67256734
}
67266735

67276736
void const97() { // #13301

0 commit comments

Comments
 (0)