From 7881b99547453f07d557b9254c972111d438c672 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:04:46 +0100 Subject: [PATCH] Fix #10259 debug: SymbolDatabase couldn't resolve all user defined types (#4879) --- lib/symboldatabase.cpp | 2 ++ test/testsymboldatabase.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index b93c7c67e..c17b03d6d 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -891,6 +891,8 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization() for (Scope& scope : scopeList) { if (!scope.isClassOrStructOrUnion()) continue; + if (scope.classDef && Token::simpleMatch(scope.classDef->previous(), ">")) // skip uninstantiated template + continue; if (!scope.definedType) { mBlankTypes.emplace_back(); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 47a21e319..0d4990bf3 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -267,6 +267,7 @@ private: TEST_CASE(namespaces2); TEST_CASE(namespaces3); // #3854 - unknown macro TEST_CASE(namespaces4); + TEST_CASE(needInitialization); TEST_CASE(tryCatch1); @@ -2790,6 +2791,20 @@ private: ASSERT_EQUALS(2U, fredAType->classDef->linenr()); } + void needInitialization() { // #10259 + 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()); + + settings1 = oldSettings; + } + void tryCatch1() { const char str[] = "void foo() {\n" " try { }\n"