From: Douglas Gregor Date: Tue, 12 Apr 2011 01:02:45 +0000 (+0000) Subject: Objective-C++: The global namespace is an associated namespace of an X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f25760e17af1167c6fcf24e1ea8e3fcbd0386702;p=clang Objective-C++: The global namespace is an associated namespace of an Objective-C pointer type. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129339 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 3315ab6e53..2fd799ba41 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1963,10 +1963,13 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) { case Type::Complex: break; - // These are ignored by ADL. + // If T is an Objective-C object or interface type, or a pointer to an + // object or interface type, the associated namespace is the global + // namespace. case Type::ObjCObject: case Type::ObjCInterface: case Type::ObjCObjectPointer: + Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl()); break; } diff --git a/test/SemaObjCXX/argument-dependent-lookup.mm b/test/SemaObjCXX/argument-dependent-lookup.mm new file mode 100644 index 0000000000..a25cc68888 --- /dev/null +++ b/test/SemaObjCXX/argument-dependent-lookup.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// : For the purposes of Argument-Dependent +// Lookup, Objective-C classes are considered to be in the global +// namespace. + +@interface NSFoo +@end + +template +void f(T t) { + g(t); +} + +void g(NSFoo*); + +void test(NSFoo *foo) { + f(foo); +}