File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -2510,6 +2510,8 @@ const Function* Scope::findFunction(const Token *tok) const
25102510 for (std::size_t i = 0 ; i < definedType->derivedFrom .size (); ++i) {
25112511 const Type *base = definedType->derivedFrom [i].type ;
25122512 if (base && base->classScope ) {
2513+ if (base->classScope == this ) // Ticket #5125: Recursive class; tok should have been found already
2514+ continue ;
25132515 const Function * func = base->classScope ->findFunction (tok);
25142516 if (func)
25152517 return func;
Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ class TestSymbolDatabase: public TestFixture {
199199 TEST_CASE (symboldatabase35); // ticket #4806 (segmentation fault)
200200 TEST_CASE (symboldatabase36); // ticket #4892 (segmentation fault)
201201 TEST_CASE (symboldatabase37);
202+ TEST_CASE (symboldatabase38); // ticket #5125 (infinite recursion)
202203
203204 TEST_CASE (isImplicitlyVirtual);
204205
@@ -1639,6 +1640,18 @@ class TestSymbolDatabase: public TestFixture {
16391640 ASSERT (db && db->getVariableFromVarId (3 ) && db->getVariableFromVarId (3 )->type () && db->getVariableFromVarId (3 )->type ()->name () == " Barney" );
16401641 }
16411642
1643+ void symboldatabase38 () { // ticket #5125
1644+ check (" template <typename T = class service> struct scoped_service;\n "
1645+ " struct service {};\n "
1646+ " template <> struct scoped_service<service> {};\n "
1647+ " template <typename T>\n "
1648+ " struct scoped_service : scoped_service<service>\n "
1649+ " {\n "
1650+ " scoped_service( T* ptr ) : scoped_service<service>(ptr), m_ptr(ptr) {}\n "
1651+ " T* const m_ptr;\n "
1652+ " };" );
1653+ }
1654+
16421655 void isImplicitlyVirtual () {
16431656 {
16441657 GET_SYMBOL_DB (" class Base {\n "
You can’t perform that action at this time.
0 commit comments