1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

fix bug 89828

This commit is contained in:
Andrew Niefer 2005-04-01 15:38:01 +00:00
parent 7abf1397a2
commit f7566ee272
2 changed files with 34 additions and 6 deletions

View file

@ -3138,5 +3138,22 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue( col.getName(2).resolveBinding() instanceof ICPPClassType );
assertTrue( col.getName(3).resolveBinding() instanceof ICPPClassType );
}
public void testBug89828() throws Exception {
IASTTranslationUnit tu = parse( "class B * b; void f(); void f( int );", ParserLanguage.CPP ); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector();
tu.accept( col );
assertTrue( col.getName(0).resolveBinding() instanceof ICPPClassType );
assertTrue( col.getName(1).resolveBinding() instanceof ICPPVariable );
IFunction f1 = (IFunction) col.getName(2).resolveBinding();
IFunction f2 = (IFunction) col.getName(3).resolveBinding();
IScope scope = tu.getScope();
IBinding [] bs = scope.find("f"); //$NON-NLS-1$
assertEquals( bs.length, 2 );
assertSame( bs[0], f1 );
assertSame( bs[1], f2 );
}
}

View file

@ -1301,6 +1301,7 @@ public class CPPSemantics {
return (IBinding) bindings[0];
}
if( name.getPropertyInParent() != STRING_LOOKUP_PROPERTY ) {
LookupData data = createLookupData( name, false );
data.foundItems = bindings;
try {
@ -1310,6 +1311,16 @@ public class CPPSemantics {
}
}
IBinding [] result = null;
for ( int i = 0; i < bindings.length; i++ ) {
if( bindings[i] instanceof IASTName )
result = (IBinding[]) ArrayUtil.append( IBinding.class, result, ((IASTName)bindings[i]).resolveBinding() );
else if( bindings[i] instanceof IBinding )
result = (IBinding[]) ArrayUtil.append( IBinding.class, result, bindings[i] );
}
return new CPPCompositeBinding( result );
}
static public boolean declaredBefore( Object obj, IASTNode node ){
if( node == null ) return true;
if( node.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return true;