diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 84089d1ee74..963cc56d81f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -2204,7 +2204,25 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPFunction fn= bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class); } - // // Brian W.'s example from bugzilla#167098 + // template + // struct A {}; + // + // template + // A a(T p); + // + // void f(A p); + // + // typedef int& B; + // + // void test(B x) { + // f(a(x)); + // } + public void testFunctionTemplate_264963() throws Exception { + BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); + bh.assertNonProblem("f(a(x));", 1, ICPPFunction.class); + } + + // // Brian W.'s example from bugzilla#167098 // template // class D { //CPPClassTemplate // public: @@ -3804,5 +3822,4 @@ public class AST2TemplateTests extends AST2BaseTest { String code= getAboveComment(); parseAndCheckBindings(code, ParserLanguage.CPP); } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 1f82f836d7b..bb4834f6d44 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -1486,27 +1486,28 @@ public class CPPTemplates { * - If A is an array type, the pointer type produced by the array-to-pointer conversion is used instead * - If A is a function type, the pointer type produced by the function-to-pointer conversion is used instead * - If A is a cv-qualified type, the top level cv-qualifiers are ignored for type deduction - * @param aInfo + * @param type * @return */ - static private IType getArgumentTypeForDeduction(IType aType, boolean pIsAReferenceType) { - if (aType instanceof ICPPReferenceType) { + static private IType getArgumentTypeForDeduction(IType type, boolean pIsAReferenceType) { + type = SemanticUtil.getSimplifiedType(type); + if (type instanceof ICPPReferenceType) { try { - aType = ((ICPPReferenceType) aType).getType(); + type = ((ICPPReferenceType) type).getType(); } catch (DOMException e) { } } - IType result = aType; + IType result = type; if (!pIsAReferenceType) { try { - if (aType instanceof IArrayType) { - result = new CPPPointerType(((IArrayType) aType).getType()); - } else if (aType instanceof IFunctionType) { - result = new CPPPointerType(aType); - } else if (aType instanceof IQualifierType) { - result = ((IQualifierType) aType).getType(); - } else if (aType instanceof CPPPointerType) { - result = ((CPPPointerType) aType).stripQualifiers(); + if (type instanceof IArrayType) { + result = new CPPPointerType(((IArrayType) type).getType()); + } else if (type instanceof IFunctionType) { + result = new CPPPointerType(type); + } else if (type instanceof IQualifierType) { + result = ((IQualifierType) type).getType(); + } else if (type instanceof CPPPointerType) { + result = ((CPPPointerType) type).stripQualifiers(); } } catch (DOMException e) { result = e.getProblem();