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 a84b77f863f..be2c9fa8698 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 @@ -3155,5 +3155,28 @@ public class AST2CPPTests extends AST2BaseTest { assertSame( bs[0], f1 ); assertSame( bs[1], f2 ); } + + public void testBug90039() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("class A { \n"); //$NON-NLS-1$ + buffer.append(" enum type { t1, t2 }; \n"); //$NON-NLS-1$ + buffer.append(" void f( type t ); \n"); //$NON-NLS-1$ + buffer.append("}; \n"); //$NON-NLS-1$ + buffer.append("class B : public A { \n"); //$NON-NLS-1$ + buffer.append(" void g() { \n"); //$NON-NLS-1$ + buffer.append(" f( A::t1 ); \n"); //$NON-NLS-1$ + buffer.append(" } \n"); //$NON-NLS-1$ + buffer.append("}; \n"); //$NON-NLS-1$ + + IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); + CPPNameCollector col = new CPPNameCollector(); + tu.accept( col ); + + IFunction f = (IFunction) col.getName( 10 ).resolveBinding(); + IEnumerator t1 = (IEnumerator) col.getName( 13 ).resolveBinding(); + + assertInstances( col, f, 2 ); + assertInstances( col, t1, 3 ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index ce81a5d9a3c..ae24cffe6e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -59,6 +59,7 @@ import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; +import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.ILabel; @@ -739,12 +740,15 @@ public class CPPVisitor { node = null; } if( name != null ){ - IBinding binding = CPPSemantics.resolveBinding( name ); if( name instanceof ICPPASTQualifiedName ){ IASTName ns [] = ((ICPPASTQualifiedName)name).getNames(); name = ns[ ns.length - 1 ]; } - name.setBinding( binding ); + IBinding binding = name.getBinding(); + if( binding == null ){ + binding = CPPSemantics.resolveBinding( name ); + name.setBinding( binding ); + } return binding; } return null; @@ -1382,21 +1386,20 @@ public class CPPVisitor { return null; if( expression instanceof IASTIdExpression ){ IBinding binding = resolveBinding( expression ); - if( binding instanceof IVariable ){ - try { + try { + if( binding instanceof IVariable ){ return ((IVariable)binding).getType(); - } catch ( DOMException e ) { - return e.getProblem(); - } - } else if( binding instanceof IProblemBinding ){ - return (IType) binding; - } else if( binding instanceof IFunction ){ - try { + } else if( binding instanceof IEnumerator ){ + return ((IEnumerator)binding).getType(); + } else if( binding instanceof IProblemBinding ){ + return (IType) binding; + } else if( binding instanceof IFunction ){ return ((IFunction)binding).getType(); - } catch ( DOMException e ){ - return e.getProblem(); } + } catch ( DOMException e ){ + return e.getProblem(); } + } else if( expression instanceof IASTCastExpression ){ IASTTypeId id = ((IASTCastExpression)expression).getTypeId(); IType type = createType( id.getDeclSpecifier() ); @@ -1515,6 +1518,8 @@ public class CPPVisitor { return ((IVariable)binding).getType(); else if( binding instanceof IFunction ) return ((IFunction)binding).getType(); + else if( binding instanceof IEnumerator ) + return ((IEnumerator)binding).getType(); } catch ( DOMException e ) { return e.getProblem(); }