From 68e0514086b79945408509ad3a37e8cc36acebe1 Mon Sep 17 00:00:00 2001 From: Andrew Niefer Date: Thu, 19 May 2005 18:59:20 +0000 Subject: [PATCH] fix bug 95714 --- .../core/parser/tests/ast2/AST2CPPTests.java | 19 +++++++++++++++++++ .../core/dom/parser/cpp/CPPSemantics.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) 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 bf5c65422fb..b9f87d39f2c 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 @@ -4355,4 +4355,23 @@ public class AST2CPPTests extends AST2BaseTest { IASTDeclarator d = ((IASTSimpleDeclaration)ds.getDeclaration()).getDeclarators()[0]; assertTrue( d.getName().resolveBinding() instanceof IVariable ); } + + public void testBug95714() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef struct xs { \n"); //$NON-NLS-1$ + buffer.append(" int state; \n"); //$NON-NLS-1$ + buffer.append("} xs; \n"); //$NON-NLS-1$ + buffer.append("void f( xs *ci ) { \n"); //$NON-NLS-1$ + buffer.append(" ci->state; \n"); //$NON-NLS-1$ + buffer.append(" (ci - 1)->state; \n"); //$NON-NLS-1$ + buffer.append("} \n"); //$NON-NLS-1$ + + IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); + CPPNameCollector col = new CPPNameCollector(); + tu.accept(col); + + ICPPField state = (ICPPField) col.getName(1).resolveBinding(); + assertSame( state, col.getName(7).resolveBinding() ); + assertSame( state, col.getName(9).resolveBinding() ); + } } 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 07a4949d7df..b7e7645c4d3 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 @@ -1691,7 +1691,7 @@ public class CPPSemantics { ((ICPPSpecialization)temp).getSpecializedBinding() == type ) { //ok, stay with the template, the specialization, if applicable, will come out during instantiation - } else if( type != temp ) { + } else if( type != temp && !((IType)type).isSameType( (IType) temp )) { return new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name ); } } else if( temp instanceof IFunction ){