1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

Bug 458316 - Unqualified function call with dependent argument and

non-matching overload in scope at point of declaration

Change-Id: I2fc42e9ef9258c3c56791001217572fdd08f5025
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
Nathan Ridge 2015-02-05 02:38:53 -05:00 committed by Sergey Prigogin
parent 327709c58e
commit f7cf56f4c5
2 changed files with 46 additions and 16 deletions

View file

@ -8184,7 +8184,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testUnqualifiedFunctionCallInTemplate_402498a() throws Exception {
parseAndCheckBindings();
}
// template <typename T>
// auto foo(T t) -> decltype(bar(t));
//
@ -8222,6 +8222,36 @@ public class AST2TemplateTests extends AST2TestBase {
assertFalse(x.getType().isSameType(CommonTypes.int_));
}
// void bar();
//
// template <typename T>
// void foo(T t) {
// bar(t);
// }
public void testUnqualifiedFunctionCallInTemplate_458316a() throws Exception {
parseAndCheckBindings();
}
// void bar();
//
// template <typename T>
// auto foo(T t) -> decltype(bar(t));
//
// struct Cat { void meow(); };
//
// namespace N {
// struct S {};
//
// Cat bar(S);
// }
//
// int main() {
// foo(N::S()).meow();
// }
public void testUnqualifiedFunctionCallInTemplate_458316b() throws Exception {
parseAndCheckBindings();
}
// template <typename>
// struct no_type {};
//

View file

@ -324,12 +324,21 @@ public class CPPSemantics {
}
private static IBinding postResolution(IBinding binding, LookupData data) {
if (binding instanceof IProblemBinding)
return binding;
final IASTName lookupName = data.getLookupName();
if (lookupName == null)
return binding;
final IASTName lookupName = data.getLookupName();
if (lookupName == null)
return binding;
// If this is the unqualified name of a function in a function call in a template and some
// of the function arguments are dependent, a matching function could be found via
// argument-dependent lookup at the point of instantiation.
if (binding == null || binding instanceof IProblemBinding) {
if (!data.qualified && data.isFunctionCall() && CPPTemplates.containsDependentType(data.getFunctionArgumentTypes())) {
binding = CPPDeferredFunction.createForName(lookupName.getSimpleID());
}
}
if (binding instanceof IProblemBinding)
return binding;
IASTNode lookupPoint = data.getLookupPoint();
@ -538,15 +547,6 @@ 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) {