Skip to content
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