Skip to content

Commit f403177

Browse files
Fix #12395 debug: SymbolDatabase couldn't resolve all user defined types with static member (#5929)
1 parent a1b1293 commit f403177

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,8 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
937937
bool unknown = false;
938938

939939
for (const Variable& var: scope.varlist) {
940+
if (var.isStatic())
941+
continue;
940942
if (var.isClass() && !var.isReference()) {
941943
if (var.type()) {
942944
// does this type need initialization?
@@ -947,7 +949,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
947949
unknown = true;
948950
}
949951
}
950-
} else if (!var.hasDefault() && !var.isStatic()) {
952+
} else if (!var.hasDefault()) {
951953
needInitialization = true;
952954
break;
953955
}

test/testsymboldatabase.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,6 +3034,14 @@ class TestSymbolDatabase : public TestFixture {
30343034
"};\n");
30353035
ASSERT_EQUALS("", errout.str());
30363036
}
3037+
{
3038+
GET_SYMBOL_DB_DBG("struct S {\n" // #12395
3039+
" static S s;\n"
3040+
"};\n");
3041+
ASSERT_EQUALS("", errout.str());
3042+
const Variable* const s = db->getVariableFromVarId(1);
3043+
ASSERT(s->scope()->definedType->needInitialization == Type::NeedInitialization::False);
3044+
}
30373045
}
30383046

30393047
void tryCatch1() {

0 commit comments

Comments
 (0)