Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12367 debug: SymbolDatabase couldn't resolve all user defined types. (regression) #5895

Merged
merged 2 commits into from
Jan 19, 2024
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
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
26 changes: 17 additions & 9 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>\n"
"struct A {\n"
" using type = T;\n"
" type t_;\n"
"};\n");
ASSERT_EQUALS("", errout.str());

{
GET_SYMBOL_DB("template <typename T>\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;
}

Expand Down
4 changes: 3 additions & 1 deletion test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading