1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 01:45:33 +02:00

Bug 402498 - Name resolution error for unqualified function call with

dependent argument

Change-Id: I7de7ea4898c91f2c994b8b19e61c4f283620620e
Reviewed-on: https://git.eclipse.org/r/10922
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Nathan Ridge 2013-03-07 03:55:24 -05:00 committed by Sergey Prigogin
parent d2f798e5b8
commit 395e7c941e
3 changed files with 28 additions and 1 deletions

View file

@ -7488,4 +7488,12 @@ public class AST2TemplateTests extends AST2TestBase {
public void testRegression_401743b() throws Exception {
parseAndCheckBindings();
}
// template <typename T>
// void foo(T t) {
// bar(t);
// }
public void testUnqualifiedFunctionCallInTemplate_402498() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction, ICPPComputableFunction {
private static final ICPPFunctionType FUNCTION_TYPE=
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
private static final ICPPFunction[] NO_CANDIDATES= {};
/**
* Creates a CPPDeferredFunction given a set of overloaded functions
@ -43,6 +44,16 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
final IBinding owner = candidates[0].getOwner();
return new CPPDeferredFunction(owner, candidates[0].getNameCharArray(), candidates);
}
/**
* Creates a CPPDeferredFunction given a name. This is for cases where there
* are no candidates that could be passed to createForCandidates().
* @param name the name of the function
* @return the constructed CPPDeferredFunction
*/
public static ICPPFunction createForName(char[] name) {
return new CPPDeferredFunction(null, name, NO_CANDIDATES);
}
private final IBinding fOwner;
private final ICPPFunction[] fCandidates;

View file

@ -518,6 +518,15 @@ public class CPPSemantics {
}
}
// If this is the unqualified name of a function in a function call in a template and some
// of the function arguments are dependent, the name could be resolved via argument-dependent
// lookup at the point of instantiation.
if (binding == null) {
if (!data.qualified && data.isFunctionCall() && CPPTemplates.containsDependentType(data.getFunctionArgumentTypes())) {
binding = CPPDeferredFunction.createForName(lookupName.getSimpleID());
}
}
// If we're still null...
if (binding == null) {
if (name instanceof ICPPASTQualifiedName && declaration != null) {
@ -555,7 +564,6 @@ public class CPPSemantics {
private static void doKoenigLookup(LookupData data) throws DOMException {
data.ignoreUsingDirectives = true;
data.qualified = true;
Set<ICPPFunction> friendFns = new HashSet<ICPPFunction>(2);
Set<ICPPNamespaceScope> associated = getAssociatedScopes(data, friendFns);
for (ICPPNamespaceScope scope : associated) {