Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2005-05-13 20:36:07 +0000
committerAndrew Niefer2005-05-13 20:36:07 +0000
commit8558156ee290438827131acda215f82978dc1af8 (patch)
treea1a745d35866ccb278a0d36d4d01c12356d5d63f
parent6ccc4b446219c466d723992c34b05383d0604824 (diff)
downloadorg.eclipse.cdt-8558156ee290438827131acda215f82978dc1af8.tar.gz
org.eclipse.cdt-8558156ee290438827131acda215f82978dc1af8.tar.xz
org.eclipse.cdt-8558156ee290438827131acda215f82978dc1af8.zip
fix bug 95200 - targeted function resolution
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java5
2 files changed, 22 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 2c6c5ad02d4..fe38527c55a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -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 );
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
index 224353dfc16..fb46eb7a170 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
@@ -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 );

Back to the top