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"