diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 47199e0e4..cb6d9ecdb 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -134,7 +134,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() tok->progressValue()); // Locate next class if ((mTokenizer->isCPP() && tok->isKeyword() && - ((Token::Match(tok, "class|struct|union|namespace ::| %name% {|:|::|<") && + ((Token::Match(tok, "class|struct|union|namespace ::| %name% final| {|:|::|<") && !Token::Match(tok->previous(), "new|friend|const|enum|typedef|mutable|volatile|using|)|(|<")) || (Token::Match(tok, "enum class| %name% {") || Token::Match(tok, "enum class| %name% : %name% {")))) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 15960b5f7..64ba06069 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -353,6 +353,7 @@ private: TEST_CASE(symboldatabase94); // structured bindings TEST_CASE(symboldatabase95); // #10295 TEST_CASE(symboldatabase96); // #10126 + TEST_CASE(symboldatabase97); // #10598 - final class TEST_CASE(createSymbolDatabaseFindAllScopes1); TEST_CASE(createSymbolDatabaseFindAllScopes2); @@ -4817,6 +4818,19 @@ private: ASSERT_EQUALS("", errout.str()); } + void symboldatabase97() { // #10598 - final class + GET_SYMBOL_DB("template<> struct A final {\n" + " A() {}\n" + "};\n"); + ASSERT(db); + ASSERT_EQUALS(3, db->scopeList.size()); + + const Token *functok = Token::findmatch(tokenizer.tokens(), "%name% ("); + ASSERT(functok); + ASSERT(functok->function()); + ASSERT_EQUALS(functok->function()->type, Function::Type::eConstructor); + } + void createSymbolDatabaseFindAllScopes1() { GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); ASSERT(db->scopeList.size() == 3);