diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8d2e224e2..526998c01 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2510,7 +2510,7 @@ 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 + if (base->classScope == this) // Ticket #5120, #5125: Recursive class; tok should have been found already continue; const Function * func = base->classScope->findFunction(tok); if (func) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 15bfed353..d52cbc83f 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -200,6 +200,7 @@ private: TEST_CASE(symboldatabase36); // ticket #4892 (segmentation fault) TEST_CASE(symboldatabase37); TEST_CASE(symboldatabase38); // ticket #5125 (infinite recursion) + TEST_CASE(symboldatabase39); // ticket #5120 (infinite recursion) TEST_CASE(isImplicitlyVirtual); @@ -1652,6 +1653,10 @@ private: "};"); } + void symboldatabase39() { // ticket #5120 + check("struct V : { public case {} ; struct U : U void { V *f (int x) (x) } }"); + } + void isImplicitlyVirtual() { { GET_SYMBOL_DB("class Base {\n"