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 6048cb9b78b..abe7e48a1cf 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 @@ -2270,6 +2270,17 @@ public class AST2TemplateTests extends AST2BaseTest { parseAndCheckBindings(code, ParserLanguage.CPP); } + + // template void f1(void(*f)(const U&)) {} + // void f2(const int& b){} + // void test() { + // f1(&f2); // problem on f1 + // } + public void testSimplifiedFunctionTemplateWithFunctionPointer_281783() throws Exception { + final String code = getAboveComment(); + parseAndCheckBindings(code, ParserLanguage.CPP); + } + // template // class A {}; // @@ -2283,7 +2294,7 @@ public class AST2TemplateTests extends AST2BaseTest { // void test(A x) { // f1(x, &f2); // } - public void _testFunctionTemplateWithFunctionPointer_281783() throws Exception { + public void testFunctionTemplateWithFunctionPointer_281783() throws Exception { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); bh.assertNonProblem("f1(x, &f2);", 2, ICPPFunction.class); } 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 8106b9d598f..02999758053 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 @@ -1599,6 +1599,12 @@ public class CPPTemplates { } p = ((IPointerType) p).getType(); a = ((IPointerType) a).getType(); + } else if (p instanceof ICPPReferenceType) { + if (!(a instanceof ICPPReferenceType)) { + return false; + } + p = ((ICPPReferenceType) p).getType(); + a = ((ICPPReferenceType) a).getType(); } else if (p instanceof IQualifierType) { if (a instanceof IQualifierType) { a = ((IQualifierType) a).getType(); //TODO a = strip qualifiers from p out of a