diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java index 6fea85a300c..e3f55436731 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTemplateTest.java @@ -938,4 +938,23 @@ public class CompleteParseASTTemplateTest extends CompleteParseBaseTest { IASTTemplateDeclaration foo = (IASTTemplateDeclaration) i.next(); } + public void testBug64919() throws Exception{ + Writer writer = new StringWriter(); + writer.write("class Foo{}; "); + writer.write("class Bar{}; "); + writer.write("template class A {}; "); + writer.write("template < class X > class A < X, X > : public A< X, Bar> "); + writer.write("{ typedef int TYPE; }; "); + writer.write("template < class X > class A < X, Foo > : public A< X, X > "); + writer.write("{ void f ( TYPE ); }; "); + + //success is no stack overflow + Iterator i = parse( writer.toString() ).getDeclarations(); + + IASTClassSpecifier Foo = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); + IASTClassSpecifier Bar = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); + IASTTemplateDeclaration A1 = (IASTTemplateDeclaration) i.next(); + IASTTemplateDeclaration A2 = (IASTTemplateDeclaration) i.next(); + IASTTemplateDeclaration A3 = (IASTTemplateDeclaration) i.next(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java index 551ce042392..23f6b038292 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java @@ -659,12 +659,20 @@ public class ParserSymbolTable { //if the inheritanceChain already contains the parent, then that //is circular inheritance if( ! data.inheritanceChain.contains( parent ) ){ - //is this name define in this scope? - if( parent instanceof IDeferredTemplateInstance ){ - parent = ((IDeferredTemplateInstance)parent).getTemplate().getTemplatedSymbol(); - } else if( parent instanceof ITemplateSymbol ){ - parent = ((ITemplateSymbol)parent).getTemplatedSymbol(); + if( parent instanceof IDeferredTemplateInstance || parent instanceof ITemplateSymbol ){ + if( parent instanceof IDeferredTemplateInstance ){ + parent = ((IDeferredTemplateInstance)parent).getTemplate().getTemplatedSymbol(); + } else if( parent instanceof ITemplateSymbol ){ + parent = ((ITemplateSymbol)parent).getTemplatedSymbol(); + } + if( data.inheritanceChain.contains( parent ) ){ + //bug 64919, might not really be circular inheritance, it just looks that way + //don't throw an exception, just ignore this parent. + continue; + } } + + //is this name define in this scope? if( parent instanceof IDerivableContainerSymbol ){ temp = lookupInContained( data, (IDerivableContainerSymbol) parent ); } else {