diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 966e8aa0c..8d2e224e2 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2510,6 +2510,8 @@ const Function* Scope::findFunction(const Token *tok) const for (std::size_t i = 0; i < definedType->derivedFrom.size(); ++i) { const Type *base = definedType->derivedFrom[i].type; if (base && base->classScope) { + if (base->classScope == this) // Ticket #5125: Recursive class; tok should have been found already + continue; const Function * func = base->classScope->findFunction(tok); if (func) return func; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index a0179464c..15bfed353 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -199,6 +199,7 @@ private: TEST_CASE(symboldatabase35); // ticket #4806 (segmentation fault) TEST_CASE(symboldatabase36); // ticket #4892 (segmentation fault) TEST_CASE(symboldatabase37); + TEST_CASE(symboldatabase38); // ticket #5125 (infinite recursion) TEST_CASE(isImplicitlyVirtual); @@ -1639,6 +1640,18 @@ private: ASSERT(db && db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->type() && db->getVariableFromVarId(3)->type()->name() == "Barney"); } + void symboldatabase38() { // ticket #5125 + check("template struct scoped_service;\n" + "struct service {};\n" + "template <> struct scoped_service {};\n" + "template \n" + "struct scoped_service : scoped_service\n" + "{\n" + " scoped_service( T* ptr ) : scoped_service(ptr), m_ptr(ptr) {}\n" + " T* const m_ptr;\n" + "};"); + } + void isImplicitlyVirtual() { { GET_SYMBOL_DB("class Base {\n"