Skip to content

Commit

Permalink
Defer resolving function set if target is deferred class or constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
i-garrison authored and jonahgraham committed Mar 16, 2023
1 parent a89ce59 commit c69eed4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11493,4 +11493,42 @@ public void testBinaryExpressionWithVariableTemplateDeep() throws Exception {
public void testBinaryExpressionWithVariableTemplate_bug497931_comment8() throws Exception {
parseAndCheckBindings();
}

// template<typename T>
// static T* return_self (T *self);
//
// template<typename T>
// struct boolean_option_def
// {
// boolean_option_def (bool *(*callback) (T *));
// };
//
// template<typename T> struct S {
// boolean_option_def<T> def;
//
// S() : def(return_self) {}
// };
//
// S<bool> bool_s_test;
public void testResolveFunctionTemplateInDeferredClassArg() throws Exception {
parseAndCheckBindings();
}

// template<typename T>
// static T* return_self (T *self);
//
// template<typename T>
// struct boolean_option_def
// {
// boolean_option_def (bool *(*callback) (T *));
// };
//
// template<typename T> struct S : public boolean_option_def<T> {
// S() : boolean_option_def<T>(return_self) {}
// };
//
// S<bool> bool_s_test;
public void testResolveFunctionTemplateInDeferredBaseArg() throws Exception {
parseAndCheckBindings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
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;
Expand Down Expand Up @@ -3344,6 +3345,15 @@ static IBinding resolveTargetedFunction(IASTName name, CPPFunctionSet functionSe
}
}
}

// 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.
Expand Down

0 comments on commit c69eed4

Please sign in to comment.