diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index e70f1be95..b565e1030 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3462,7 +3462,10 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n if (!function) { const Scope * scope = ns->findRecordInNestedList(func->str()); if (scope && func->strAt(1) == "::") { - function = findFunctionInScope(func->tokAt(2), scope); + func = func->tokAt(2); + if (func->str() == "~") + func = func->next(); + function = findFunctionInScope(func, scope); } } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 4a0210a98..1e973e3c4 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -219,6 +219,7 @@ private: TEST_CASE(symboldatabase44); TEST_CASE(symboldatabase45); // #6125 TEST_CASE(symboldatabase46); // #6171 (anonymous namespace) + TEST_CASE(symboldatabase47); // #6308 TEST_CASE(isImplicitlyVirtual); @@ -1998,6 +1999,19 @@ private: ASSERT_EQUALS(scope->className, "S"); } + void symboldatabase47() { // #6308 - associate Function and Scope for destructors + GET_SYMBOL_DB("namespace NS {\n" + " class MyClass {\n" + " ~MyClass();\n" + " };\n" + "}\n" + "using namespace NS;\n" + "MyClass::~MyClass() {\n" + " delete Example;\n" + "}"); + ASSERT(db && !db->functionScopes.empty() && db->functionScopes.front()->function && db->functionScopes.front()->function->functionScope == db->functionScopes.front()); + } + void isImplicitlyVirtual() { { GET_SYMBOL_DB("class Base {\n"