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 d4543d13c59..b836f2b06f8 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 @@ -4806,5 +4806,20 @@ public class AST2CPPTests extends AST2BaseTest { assertSame( b, col.getName(8).resolveBinding() ); assertSame( a, col.getName(9).resolveBinding() ); assertSame( b, col.getName(10).resolveBinding() ); - } + } + + public void testBug100415() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("void free( void * ); \n"); + buffer.append("void f( char **p ){ \n"); + buffer.append(" free( p ); \n"); + buffer.append("} \n"); + + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, true, true ); + CPPNameCollector col = new CPPNameCollector(); + tu.accept( col ); + + IFunction free = (IFunction) col.getName(0).resolveBinding(); + assertSame( free, col.getName(4).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 02b37c53aeb..a384ec37d96 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 @@ -2454,7 +2454,7 @@ public class CPPSemantics { qualificationConversion( cost ); //if we can't convert the qualifications, then we can't do anything - if( cost.qualification == 0 ){ + if( cost.qualification == Cost.NO_MATCH_RANK ){ return cost; } @@ -2655,7 +2655,7 @@ public class CPPSemantics { static private void qualificationConversion( Cost cost ) throws DOMException{ boolean canConvert = true; - int conversionRequired = 1; //1 means it will work without a conversion, 2 means conversion was needed + int requiredConversion = Cost.IDENTITY_RANK; IPointerType op1, op2; IType s = cost.source, t = cost.target; @@ -2694,6 +2694,7 @@ public class CPPSemantics { //if const is in cv1,j then const is in cv2,j. Similary for volatile if( ( op1.isConst() && !op2.isConst() ) || ( op1.isVolatile() && !op2.isVolatile() ) ) { canConvert = false; + requiredConversion = Cost.NO_MATCH_RANK; break; } //if cv1,j and cv2,j are different then const is in every cv2,k for 0 -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK; cost.conversion = ( temp > -1 ) ? temp : 0; cost.detail = 1; return; } - } else if( t instanceof IBasicType && s instanceof IBasicType || s instanceof IEnumeration ){ + } + if( t instanceof IBasicType && s instanceof IBasicType || s instanceof IEnumeration ){ //4.7 An rvalue of an integer type can be converted to an rvalue of another integer type. //An rvalue of an enumeration type can be converted to an rvalue of an integer type. cost.rank = Cost.CONVERSION_RANK;