diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index bc60164fb..2e0eba604 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -93,13 +93,16 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() else if (_tokenizer->isCPP() && tok->strAt(1) == "class") tok2 = tok2->next(); - while (tok2 && tok2->str() == "::") + while (Token::Match(tok2, ":: %name%")) tok2 = tok2->tokAt(2); // skip over template args if (tok2 && tok2->str() == "<" && tok2->link()) tok2 = tok2->link()->next(); + if (Token::Match(tok2, "%name% [")) + continue; + // make sure we have valid code if (!Token::Match(tok2, "{|:")) { // check for qualified variable diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 0042605aa..0fd9f3754 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -270,6 +270,7 @@ private: TEST_CASE(symboldatabase56); // #7909 TEST_CASE(symboldatabase57); TEST_CASE(symboldatabase58); // #6985 (using namespace type lookup) + TEST_CASE(symboldatabase59); TEST_CASE(enum1); TEST_CASE(enum2); @@ -2879,6 +2880,13 @@ private: } } + void symboldatabase59() { // #8465 + GET_SYMBOL_DB("struct A::B ab[10];\n" + "void f() {}"); + ASSERT(db != nullptr); + ASSERT(db && db->scopeList.size() == 2); + } + void enum1() { GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");