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 7b0caad42a7..e7d22b0aeda 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 @@ -123,7 +123,6 @@ import org.eclipse.cdt.internal.core.parser.ParserException; public class AST2CPPTests extends AST2BaseTest { - public AST2CPPTests() { } @@ -6013,4 +6012,18 @@ public class AST2CPPTests extends AST2BaseTest { public void testScopeOfCatchHandler_Bug209579() throws Exception { parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); } + + // void func(const char& c); + // void func(char& c); + // + // void test(const char& x, char& y) { + // func(x); + // func(y); + // } + public void testOverloadedFunction_248774() throws Exception { + BindingAssertionHelper helper= new BindingAssertionHelper(getAboveComment(), true); + ICPPFunction func1= helper.assertNonProblem("func(x)", 4, ICPPFunction.class); + ICPPFunction func2= helper.assertNonProblem("func(y)", 4, ICPPFunction.class); + assertNotSame(func1, func2); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java index 9546d29f263..4dbb14862f7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -611,6 +611,9 @@ public class Conversions { firstPointer= false; } + if (cost.targetHadReference && s instanceof ICPPReferenceType) { + s = ((ICPPReferenceType) s).getType(); + } if (s instanceof IQualifierType ^ t instanceof IQualifierType) { if (t instanceof IQualifierType) { if (!constInEveryCV2k) { @@ -623,11 +626,10 @@ public class Conversions { } else { //4.2-2 a string literal can be converted to pointer to char if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_char && - s instanceof IQualifierType) - { - IType qt = ((IQualifierType)s).getType(); + s instanceof IQualifierType) { + IType qt = ((IQualifierType) s).getType(); if (qt instanceof IBasicType) { - IASTExpression val = ((IBasicType)qt).getValue(); + IASTExpression val = ((IBasicType) qt).getValue(); canConvert = (val != null && val instanceof IASTLiteralExpression && ((IASTLiteralExpression)val).getKind() == IASTLiteralExpression.lk_string_literal); @@ -641,7 +643,8 @@ public class Conversions { } } } else if (s instanceof IQualifierType && t instanceof IQualifierType) { - IQualifierType qs = (IQualifierType) s, qt = (IQualifierType) t; + IQualifierType qs = (IQualifierType) s; + IQualifierType qt = (IQualifierType) t; if (qs.isConst() == qt.isConst() && qs.isVolatile() == qt.isVolatile()) { requiredConversion = Cost.IDENTITY_RANK; } else if ((qs.isConst() && !qt.isConst()) || (qs.isVolatile() && !qt.isVolatile()) || !constInEveryCV2k) { @@ -654,18 +657,18 @@ public class Conversions { canConvert = true; requiredConversion = Cost.CONVERSION_RANK; int i = 1; - for (IType type = s; canConvert == true && i == 1; type = t, i++) { + for (IType type = s; canConvert && i == 1; type = t, i++) { while (type instanceof ITypeContainer) { if (type instanceof IQualifierType) { canConvert = false; } else if (type instanceof IPointerType) { - canConvert = !((IPointerType)type).isConst() && !((IPointerType)type).isVolatile(); + canConvert = !((IPointerType) type).isConst() && !((IPointerType) type).isVolatile(); } if (!canConvert) { requiredConversion = Cost.NO_MATCH_RANK; break; } - type = ((ITypeContainer)type).getType(); + type = ((ITypeContainer) type).getType(); } } }