mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 02:15:31 +02:00
fix bug 64919 - stack overflow in symbol table
This commit is contained in:
parent
424cfd2211
commit
d4c76e1e98
2 changed files with 32 additions and 5 deletions
|
@ -938,4 +938,23 @@ public class CompleteParseASTTemplateTest extends CompleteParseBaseTest {
|
||||||
IASTTemplateDeclaration foo = (IASTTemplateDeclaration) i.next();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -659,12 +659,20 @@ public class ParserSymbolTable {
|
||||||
//if the inheritanceChain already contains the parent, then that
|
//if the inheritanceChain already contains the parent, then that
|
||||||
//is circular inheritance
|
//is circular inheritance
|
||||||
if( ! data.inheritanceChain.contains( parent ) ){
|
if( ! data.inheritanceChain.contains( parent ) ){
|
||||||
//is this name define in this scope?
|
if( parent instanceof IDeferredTemplateInstance || parent instanceof ITemplateSymbol ){
|
||||||
if( parent instanceof IDeferredTemplateInstance ){
|
if( parent instanceof IDeferredTemplateInstance ){
|
||||||
parent = ((IDeferredTemplateInstance)parent).getTemplate().getTemplatedSymbol();
|
parent = ((IDeferredTemplateInstance)parent).getTemplate().getTemplatedSymbol();
|
||||||
} else if( parent instanceof ITemplateSymbol ){
|
} else if( parent instanceof ITemplateSymbol ){
|
||||||
parent = ((ITemplateSymbol)parent).getTemplatedSymbol();
|
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 ){
|
if( parent instanceof IDerivableContainerSymbol ){
|
||||||
temp = lookupInContained( data, (IDerivableContainerSymbol) parent );
|
temp = lookupInContained( data, (IDerivableContainerSymbol) parent );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue