Skip to content

Commit 8a1792f

Browse files
committed
Move to finalize
1 parent b845dd3 commit 8a1792f

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎lib/symboldatabase.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ SymbolDatabase::SymbolDatabase(Tokenizer& tokenizer)
140140
createSymbolDatabaseFunctionScopes();
141141
createSymbolDatabaseClassAndStructScopes();
142142
createSymbolDatabaseFunctionReturnTypes();
143+
// before the variable symbol table fills in the member types that the first lookup missed
144+
createSymbolDatabaseNeedInitialization();
143145
createSymbolDatabaseVariableSymbolTable();
144146
createSymbolDatabaseSetScopePointers();
145147
createSymbolDatabaseSetVariablePointers();
@@ -157,7 +159,6 @@ void SymbolDatabase::finalize()
157159
return;
158160

159161
createSymbolDatabaseCopyAndMoveConstructors();
160-
createSymbolDatabaseNeedInitialization();
161162
createSymbolDatabaseEscapeFunctions();
162163
createSymbolDatabaseIncompleteVars();
163164
createSymbolDatabaseExprIds();
@@ -2157,6 +2158,9 @@ void SymbolDatabase::addSymbolsForNewTokenRanges(const std::vector<std::pair<Tok
21572158
classAndStructScopes.push_back(scope);
21582159
}
21592160

2161+
// the new classes - as in the constructor, before their member types are filled in
2162+
createSymbolDatabaseNeedInitialization();
2163+
21602164
// variable symbol table: add the new variables (incremental version of
21612165
// createSymbolDatabaseVariableSymbolTable)
21622166
for (Scope* scope : newScopes)

‎test/testsymboldatabase.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,6 +3473,15 @@ class TestSymbolDatabase : public TestFixture {
34733473
const Variable* const s = db->getVariableFromVarId(1);
34743474
ASSERT(s->scope()->definedType->needInitialization == Type::NeedInitialization::False);
34753475
}
3476+
{ // member of a forward declared type with a qualified name
3477+
GET_SYMBOL_DB_DBG("namespace N { struct T; }\n"
3478+
"struct S {\n"
3479+
" N::T t;\n"
3480+
"};\n");
3481+
ASSERT_EQUALS("", errout_str());
3482+
const Variable* const t = db->getVariableFromVarId(1);
3483+
ASSERT(t->scope()->definedType->needInitialization == Type::NeedInitialization::False);
3484+
}
34763485
}
34773486

34783487
void tryCatch1() {

0 commit comments

Comments
 (0)