mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 22:35:43 +02:00
fix bug 95200 - targeted function resolution
This commit is contained in:
parent
6ccc4b4462
commit
8558156ee2
2 changed files with 22 additions and 2 deletions
|
@ -4023,5 +4023,22 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertFalse( col.getName(15).isDefinition() ); //g
|
||||
assertTrue( col.getName(18).isDefinition() ); //pf
|
||||
}
|
||||
|
||||
|
||||
public void testBug95200() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "int f(double); \n"); //$NON-NLS-1$
|
||||
buffer.append( "int f(int); \n"); //$NON-NLS-1$
|
||||
buffer.append( "int (&rfi)(int) = f; \n"); //$NON-NLS-1$
|
||||
buffer.append( "int (&rfd)(double) = f; \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunction f1 = (ICPPFunction) col.getName(0).resolveBinding();
|
||||
ICPPFunction f2 = (ICPPFunction) col.getName(2).resolveBinding();
|
||||
|
||||
assertSame( col.getName(6).resolveBinding(), f2 );
|
||||
assertSame( col.getName(9).resolveBinding(), f1 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2181,7 +2181,10 @@ public class CPPSemantics {
|
|||
while( node != null ){
|
||||
prop = node.getPropertyInParent();
|
||||
//target is an object or reference being initialized
|
||||
if( prop == IASTInitializerExpression.INITIALIZER_EXPRESSION ){
|
||||
if( prop == IASTDeclarator.INITIALIZER ){
|
||||
IASTDeclarator dtor = (IASTDeclarator) node.getParent();
|
||||
return CPPVisitor.createType( dtor );
|
||||
} else if( prop == IASTInitializerExpression.INITIALIZER_EXPRESSION ){
|
||||
IASTInitializerExpression initExp = (IASTInitializerExpression) node.getParent();
|
||||
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
||||
return CPPVisitor.createType( dtor );
|
||||
|
|
Loading…
Add table
Reference in a new issue