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 #12395 debug: SymbolDatabase couldn't resolve all user defined types with static member #5929

Merged
merged 1 commit into from
Jan 31, 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
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 @@ -3013,6 +3013,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
Loading