Skip to content

Commit 59fde1e

Browse files
Fix #12367 debug: SymbolDatabase couldn't resolve all user defined types. (regression) (#5895)
1 parent f80effe commit 59fde1e

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

lib/symboldatabase.cpp

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

939939
for (const Variable& var: scope.varlist) {
940-
if (var.isClass()) {
940+
if (var.isClass() && !var.isReference()) {
941941
if (var.type()) {
942942
// does this type need initialization?
943943
if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault() && !var.isStatic())

test/testsymboldatabase.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,17 +3002,25 @@ class TestSymbolDatabase : public TestFixture {
30023002
ASSERT_EQUALS(2U, fredAType->classDef->linenr());
30033003
}
30043004

3005-
void needInitialization() { // #10259
3005+
void needInitialization() {
30063006
const auto oldSettings = settings1;
30073007
settings1.debugwarnings = true;
3008-
3009-
GET_SYMBOL_DB("template <typename T>\n"
3010-
"struct A {\n"
3011-
" using type = T;\n"
3012-
" type t_;\n"
3013-
"};\n");
3014-
ASSERT_EQUALS("", errout.str());
3015-
3008+
{
3009+
GET_SYMBOL_DB("template <typename T>\n" // #10259
3010+
"struct A {\n"
3011+
" using type = T;\n"
3012+
" type t_;\n"
3013+
"};\n");
3014+
ASSERT_EQUALS("", errout.str());
3015+
}
3016+
{
3017+
GET_SYMBOL_DB("class T;\n" // #12367
3018+
"struct S {\n"
3019+
" S(T& t);\n"
3020+
" T& _t;\n"
3021+
"};\n");
3022+
ASSERT_EQUALS("", errout.str());
3023+
}
30163024
settings1 = oldSettings;
30173025
}
30183026

test/testuninitvar.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5562,7 +5562,9 @@ class TestUninitVar : public TestFixture {
55625562
" p = new S(io);\n"
55635563
" p->Write();\n"
55645564
"}");
5565-
ASSERT_EQUALS("", errout.str());
5565+
TODO_ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:10]: (warning) Uninitialized variable: p\n",
5566+
"[test.cpp:8] -> [test.cpp:10]: (warning) Uninitialized variable: p.rIo\n",
5567+
errout.str());
55665568

55675569
// Unknown types
55685570
{

0 commit comments

Comments
 (0)