From a113e7263c5337731c65fada9de7ff72af25423b Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 26 Jan 2010 06:04:06 +0000 Subject: [PATCH] Allow ADL to find functions imported by using decls. Leave wordy comment about interaction between ADL and default arguments. Shrug shoulders, commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94524 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaLookup.cpp | 24 ++++++++++++++---------- lib/Sema/SemaOverload.cpp | 9 +++++++-- test/SemaCXX/using-decl-1.cpp | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 5b03fa48c3..c61d666c4b 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1785,16 +1785,20 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, bool Operator, continue; } - // FIXME: using decls? canonical decls? - - FunctionDecl *Fn; - if (!Operator || !(Fn = dyn_cast(D)) || - IsAcceptableNonMemberOperatorCandidate(Fn, T1, T2, Context)) { - if (isa(D)) - Functions.insert(D); - else if (isa(D)) - Functions.insert(D); - } + if (isa(D)) + D = cast(D)->getTargetDecl(); + + // FIXME: canonical decls. + // See comment in AddArgumentDependentLookupCandidates(). + + if (isa(D)) { + if (Operator && + !IsAcceptableNonMemberOperatorCandidate(cast(D), + T1, T2, Context)) + continue; + Functions.insert(D); + } else if (isa(D)) + Functions.insert(D); } } } diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 54db885e23..a4c11b077a 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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); diff --git a/test/SemaCXX/using-decl-1.cpp b/test/SemaCXX/using-decl-1.cpp index e8a7d70976..eb41e6630f 100644 --- a/test/SemaCXX/using-decl-1.cpp +++ b/test/SemaCXX/using-decl-1.cpp @@ -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'}} + } +} -- 2.50.1