mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +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:
parent
d2f798e5b8
commit
395e7c941e
3 changed files with 28 additions and 1 deletions
|
@ -7488,4 +7488,12 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
public void testRegression_401743b() throws Exception {
|
public void testRegression_401743b() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// void foo(T t) {
|
||||||
|
// bar(t);
|
||||||
|
// }
|
||||||
|
public void testUnqualifiedFunctionCallInTemplate_402498() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction, ICPPComputableFunction {
|
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction, ICPPComputableFunction {
|
||||||
private static final ICPPFunctionType FUNCTION_TYPE=
|
private static final ICPPFunctionType FUNCTION_TYPE=
|
||||||
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
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
|
* Creates a CPPDeferredFunction given a set of overloaded functions
|
||||||
|
@ -44,6 +45,16 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
|
||||||
return new CPPDeferredFunction(owner, candidates[0].getNameCharArray(), candidates);
|
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 IBinding fOwner;
|
||||||
private final ICPPFunction[] fCandidates;
|
private final ICPPFunction[] fCandidates;
|
||||||
|
|
||||||
|
|
|
@ -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 we're still null...
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
if (name instanceof ICPPASTQualifiedName && declaration != null) {
|
if (name instanceof ICPPASTQualifiedName && declaration != null) {
|
||||||
|
@ -555,7 +564,6 @@ public class CPPSemantics {
|
||||||
|
|
||||||
private static void doKoenigLookup(LookupData data) throws DOMException {
|
private static void doKoenigLookup(LookupData data) throws DOMException {
|
||||||
data.ignoreUsingDirectives = true;
|
data.ignoreUsingDirectives = true;
|
||||||
data.qualified = true;
|
|
||||||
Set<ICPPFunction> friendFns = new HashSet<ICPPFunction>(2);
|
Set<ICPPFunction> friendFns = new HashSet<ICPPFunction>(2);
|
||||||
Set<ICPPNamespaceScope> associated = getAssociatedScopes(data, friendFns);
|
Set<ICPPNamespaceScope> associated = getAssociatedScopes(data, friendFns);
|
||||||
for (ICPPNamespaceScope scope : associated) {
|
for (ICPPNamespaceScope scope : associated) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue