diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index bffafe3eaa3..25238d797a1 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -937,7 +937,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization() bool unknown = false; for (const Variable& var: scope.varlist) { - if (var.isClass()) { + if (var.isClass() && !var.isReference()) { if (var.type()) { // does this type need initialization? if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault() && !var.isStatic()) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 42fd7b33e63..93485ea322f 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -3002,17 +3002,25 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS(2U, fredAType->classDef->linenr()); } - void needInitialization() { // #10259 + void needInitialization() { const auto oldSettings = settings1; settings1.debugwarnings = true; - - GET_SYMBOL_DB("template \n" - "struct A {\n" - " using type = T;\n" - " type t_;\n" - "};\n"); - ASSERT_EQUALS("", errout.str()); - + { + GET_SYMBOL_DB("template \n" // #10259 + "struct A {\n" + " using type = T;\n" + " type t_;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } + { + GET_SYMBOL_DB("class T;\n" // #12367 + "struct S {\n" + " S(T& t);\n" + " T& _t;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } settings1 = oldSettings; } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 57209f0f9bf..0a4064a3bd8 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -5562,7 +5562,9 @@ class TestUninitVar : public TestFixture { " p = new S(io);\n" " p->Write();\n" "}"); - ASSERT_EQUALS("", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:10]: (warning) Uninitialized variable: p\n", + "[test.cpp:8] -> [test.cpp:10]: (warning) Uninitialized variable: p.rIo\n", + errout.str()); // Unknown types {