1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

Patch for Bryan - 182719 - Prevents a potential stack overflow error with virtual base classes.

This commit is contained in:
Doug Schaefer 2007-04-17 18:21:51 +00:00
parent a59c16a63a
commit fce61429ce

View file

@ -1294,33 +1294,37 @@ public class CPPSemantics {
return result; return result;
} }
public static void visitVirtualBaseClasses( LookupData data, ICPPClassType cls ){ public static void visitVirtualBaseClasses( LookupData data, ICPPClassType cls ) throws DOMException {
ICPPBase [] bases = null; if( data.inheritanceChain == null )
try { data.inheritanceChain = new ObjectSet( 2 );
bases = cls.getBases();
} catch ( DOMException e ) { IScope scope = cls.getCompositeScope();
return; if (scope != null)
} data.inheritanceChain.put( scope );
ICPPBase [] bases = cls.getBases();
for( int i = 0; i < bases.length; i++ ){ for( int i = 0; i < bases.length; i++ ){
try { IBinding b = bases[i].getBaseClass();
if( bases[i].isVirtual() ){ if (b instanceof ICPPClassType) {
if( data.visited == ObjectSet.EMPTY_SET ) IScope bScope = ((ICPPClassType)b).getCompositeScope();
data.visited = new ObjectSet(2); if( bases[i].isVirtual() ){
IBinding b = bases[i].getBaseClass(); if( data.visited == ObjectSet.EMPTY_SET )
if( b instanceof ICPPClassType ) { data.visited = new ObjectSet(2);
IScope bScope = ((ICPPClassType)b).getCompositeScope(); if (bScope != null)
if (bScope != null) data.visited.put(bScope);
data.visited.put(bScope); } else if ( !data.inheritanceChain.containsKey(bScope) ) {
} visitVirtualBaseClasses( data, (ICPPClassType) b );
} else { } else {
IBinding b = bases[i].getBaseClass(); data.problem = new ProblemBinding( null, IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, cls.getNameCharArray() );
if( b instanceof ICPPClassType ) }
visitVirtualBaseClasses( data, (ICPPClassType) b );
}
} catch ( DOMException e1 ) {
} }
} }
if (scope != null)
data.inheritanceChain.remove( scope );
} }
private static boolean checkForAmbiguity( LookupData data, Object n, Object names ) throws DOMException{ private static boolean checkForAmbiguity( LookupData data, Object n, Object names ) throws DOMException{
if( names instanceof Object[] ) { if( names instanceof Object[] ) {
names = ArrayUtil.trim( Object.class, (Object[]) names ); names = ArrayUtil.trim( Object.class, (Object[]) names );