diff options
author | Andrew Niefer | 2004-06-01 18:58:28 +0000 |
---|---|---|
committer | Andrew Niefer | 2004-06-01 18:58:28 +0000 |
commit | d4c76e1e98f881a5e9c79f56381fc13502ff81a3 (patch) | |
tree | adf81b8be96a76c19e5dabf00bba54eb2fccb4fd | |
parent | 424cfd22117ad1ff141150b1a29f00090847b989 (diff) | |
download | org.eclipse.cdt-d4c76e1e98f881a5e9c79f56381fc13502ff81a3.tar.gz org.eclipse.cdt-d4c76e1e98f881a5e9c79f56381fc13502ff81a3.tar.xz org.eclipse.cdt-d4c76e1e98f881a5e9c79f56381fc13502ff81a3.zip |
fix bug 64919 - stack overflow in symbol table
2 files changed, 32 insertions, 5 deletions
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 T, class U> 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 { |