Skip to content

Commit

Permalink
Fix #12395 debug: SymbolDatabase couldn't resolve all user defined ty…
Browse files Browse the repository at this point in the history
…pes with static member (#5929)
  • Loading branch information
chrchr-github authored Jan 31, 2024
1 parent a1b1293 commit f403177
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
bool unknown = false;

for (const Variable& var: scope.varlist) {
if (var.isStatic())
continue;
if (var.isClass() && !var.isReference()) {
if (var.type()) {
// does this type need initialization?
Expand All @@ -947,7 +949,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
unknown = true;
}
}
} else if (!var.hasDefault() && !var.isStatic()) {
} else if (!var.hasDefault()) {
needInitialization = true;
break;
}
Expand Down
8 changes: 8 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,14 @@ class TestSymbolDatabase : public TestFixture {
"};\n");
ASSERT_EQUALS("", errout.str());
}
{
GET_SYMBOL_DB_DBG("struct S {\n" // #12395
" static S s;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
const Variable* const s = db->getVariableFromVarId(1);
ASSERT(s->scope()->definedType->needInitialization == Type::NeedInitialization::False);
}
}

void tryCatch1() {
Expand Down

0 comments on commit f403177

Please sign in to comment.