mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +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
|
@ -4024,4 +4024,21 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertTrue( col.getName(18).isDefinition() ); //pf
|
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 ){
|
while( node != null ){
|
||||||
prop = node.getPropertyInParent();
|
prop = node.getPropertyInParent();
|
||||||
//target is an object or reference being initialized
|
//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();
|
IASTInitializerExpression initExp = (IASTInitializerExpression) node.getParent();
|
||||||
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
||||||
return CPPVisitor.createType( dtor );
|
return CPPVisitor.createType( dtor );
|
||||||
|
|
Loading…
Add table
Reference in a new issue