Allow ADL to find functions imported by using decls. Leave wordy comment

about interaction between ADL and default arguments.  Shrug shoulders, commit.

llvm-svn: 94524
This commit is contained in:
John McCall 2010-01-26 06:04:06 +00:00
parent 273735bc5a
commit 91f61fc921
3 changed files with 37 additions and 11 deletions

View File

@ -1785,16 +1785,20 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, bool Operator,
continue;
}
// FIXME: using decls? canonical decls?
if (isa<UsingShadowDecl>(D))
D = cast<UsingShadowDecl>(D)->getTargetDecl();
FunctionDecl *Fn;
if (!Operator || !(Fn = dyn_cast<FunctionDecl>(D)) ||
IsAcceptableNonMemberOperatorCandidate(Fn, T1, T2, Context)) {
if (isa<FunctionDecl>(D))
Functions.insert(D);
else if (isa<FunctionTemplateDecl>(D))
Functions.insert(D);
}
// FIXME: canonical decls.
// See comment in AddArgumentDependentLookupCandidates().
if (isa<FunctionDecl>(D)) {
if (Operator &&
!IsAcceptableNonMemberOperatorCandidate(cast<FunctionDecl>(D),
T1, T2, Context))
continue;
Functions.insert(D);
} else if (isa<FunctionTemplateDecl>(D))
Functions.insert(D);
}
}
}

View File

@ -4133,8 +4133,13 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
bool PartialOverloading) {
ADLFunctionSet Functions;
// FIXME: Should we be trafficking in canonical function decls throughout?
// FIXME: This approach for uniquing ADL results (and removing
// redundant candidates from the set) relies on pointer-equality,
// which means we need to key off the canonical decl. However,
// always going back to the canonical decl might not get us the
// right set of default arguments. What default arguments are
// we supposed to consider on ADL candidates, anyway?
// FIXME: Pass in the explicit template arguments?
ArgumentDependentLookup(Name, Operator, Args, NumArgs, Functions);

View File

@ -60,3 +60,20 @@ namespace P {
g(f);
}
}
// Make sure that ADL can find names brought in by using decls.
namespace test0 {
namespace ns {
class Foo {};
namespace inner {
void foo(char *); // expected-note {{no known conversion}}
}
using inner::foo;
}
void test(ns::Foo *p) {
foo(*p); // expected-error {{no matching function for call to 'foo'}}
}
}