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 359107fe7b1..36503540caa 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 @@ -11493,4 +11493,42 @@ public class AST2TemplateTests extends AST2CPPTestBase { public void testBinaryExpressionWithVariableTemplate_bug497931_comment8() throws Exception { parseAndCheckBindings(); } + + // template + // static T* return_self (T *self); + // + // template + // struct boolean_option_def + // { + // boolean_option_def (bool *(*callback) (T *)); + // }; + // + // template struct S { + // boolean_option_def def; + // + // S() : def(return_self) {} + // }; + // + // S bool_s_test; + public void testResolveFunctionTemplateInDeferredClassArg() throws Exception { + parseAndCheckBindings(); + } + + // template + // static T* return_self (T *self); + // + // template + // struct boolean_option_def + // { + // boolean_option_def (bool *(*callback) (T *)); + // }; + // + // template struct S : public boolean_option_def { + // S() : boolean_option_def(return_self) {} + // }; + // + // S bool_s_test; + public void testResolveFunctionTemplateInDeferredBaseArg() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 2bb89fad3c6..85325aea5e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -163,6 +163,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionInstance; @@ -3344,6 +3345,15 @@ public class CPPSemantics { } } } + + // Cannot resolve if target is deferred template instance or deferred constructor + if (targetType instanceof ICPPUnknownBinding || (prop == ICPPASTConstructorInitializer.ARGUMENT + && parent instanceof ICPPASTConstructorInitializer init + && init.getParent() instanceof ICPPASTConstructorChainInitializer memInit + && memInit.getMemberInitializerId().resolveBinding() instanceof ICPPDeferredFunction)) { + return CPPDeferredFunction.createForCandidates(functionSet.getBindings()); + } + if (targetType == null && parent instanceof ICPPASTExpression && parent instanceof IASTImplicitNameOwner) { // Trigger resolution of overloaded operator, which may resolve the // function set.