From af99524697333bfd973d84584288ba45798798f4 Mon Sep 17 00:00:00 2001 From: Andrew Niefer Date: Wed, 30 Mar 2005 22:48:10 +0000 Subject: [PATCH] fix bug 89539 --- .../core/parser/tests/ast2/AST2CPPTests.java | 25 +++++++++++++++++++ .../core/dom/parser/cpp/CPPSemantics.java | 11 ++++++++ 2 files changed, 36 insertions(+) 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 a9a083d565f..faa99e82949 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 @@ -3095,5 +3095,30 @@ public class AST2CPPTests extends AST2BaseTest { assertEquals( s[0], "B" ); //$NON-NLS-1$ assertTrue( alias.isGloballyQualified() ); } + + public void testBug89539() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("class A{}; \n"); //$NON-NLS-1$ + buffer.append("class B : public A { \n"); //$NON-NLS-1$ + buffer.append(" B () : A() {} \n"); //$NON-NLS-1$ + buffer.append("}; \n"); //$NON-NLS-1$ + + IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); //$NON-NLS-1$ + CPPNameCollector col = new CPPNameCollector(); + tu.accept( col ); + + ICPPClassType A1 = (ICPPClassType) col.getName(0).resolveBinding(); + ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding(); + assertSame( A1, A2 ); + + ICPPConstructor A3 = (ICPPConstructor) col.getName(4).resolveBinding(); + assertSame( A3.getScope(), A1.getCompositeScope() ); + + tu = parse( buffer.toString(), ParserLanguage.CPP ); //$NON-NLS-1$ + col = new CPPNameCollector(); + tu.accept( col ); + + assertTrue( col.getName(4).resolveBinding() instanceof ICPPConstructor ); + } } 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 9e3f8cbd03c..c8dbc88f7a4 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 @@ -199,6 +199,8 @@ public class CPPSemantics { IASTNode p1 = astName.getParent(); IASTNode p2 = p1.getParent(); + if( p1 instanceof ICPPASTConstructorChainInitializer ) + return true; if( p1 instanceof ICPPASTNamedTypeSpecifier && p2 instanceof IASTTypeId ) return p2.getParent() instanceof ICPPASTNewExpression; else if( p1 instanceof ICPPASTQualifiedName && p2 instanceof ICPPASTFunctionDeclarator ){ @@ -520,6 +522,15 @@ public class CPPSemantics { else data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY; } + } else if( parent instanceof ICPPASTConstructorChainInitializer ){ + ICPPASTConstructorChainInitializer ctorinit = (ICPPASTConstructorChainInitializer) parent; + IASTExpression val = ctorinit.getInitializerValue(); + if( val instanceof IASTExpressionList ) + data.functionParameters = ((IASTExpressionList) val ).getExpressions(); + else if( val != null ) + data.functionParameters = new IASTExpression [] { val }; + else + data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY; } if( considerAssociatedScopes && !(name.getParent() instanceof ICPPASTQualifiedName) && data.functionCall() ){