[cfe-commits] r129339 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/SemaObjCXX/argument-dependent-lookup.mm

Nico Weber thakis at chromium.org
Thu Apr 14 18:02:55 PDT 2011


Hi Doug,

this change breaks the following program, which builds fine with gcc
and used to build fine with clang:

#import <AppKit/AppKit.h>

#include <iostream>
using namespace std;

template <typename T>
inline void g(std::ostream* os, const T& val) {
  *os << val;
}

std::ostream& operator<<(std::ostream& out, const NSObject* obj) {
  return out << "asdf";
}

void f(ostream& out, const NSEvent* e) {
  g(&out, e);
}


Is this intended?

Thanks,
Nico

On Mon, Apr 11, 2011 at 6:02 PM, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Mon Apr 11 20:02:45 2011
> New Revision: 129339
>
> URL: http://llvm.org/viewvc/llvm-project?rev=129339&view=rev
> Log:
> Objective-C++: The global namespace is an associated namespace of an
> Objective-C pointer type. Fixes <rdar://problem/9142559>.
>
> Added:
>    cfe/trunk/test/SemaObjCXX/argument-dependent-lookup.mm
> Modified:
>    cfe/trunk/lib/Sema/SemaLookup.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=129339&r1=129338&r2=129339&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Apr 11 20:02:45 2011
> @@ -1963,10 +1963,13 @@
>     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;
>     }
>
>
> Added: cfe/trunk/test/SemaObjCXX/argument-dependent-lookup.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/argument-dependent-lookup.mm?rev=129339&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaObjCXX/argument-dependent-lookup.mm (added)
> +++ cfe/trunk/test/SemaObjCXX/argument-dependent-lookup.mm Mon Apr 11 20:02:45 2011
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +
> +// <rdar://problem/9142559>: For the purposes of Argument-Dependent
> +// Lookup, Objective-C classes are considered to be in the global
> +// namespace.
> +
> + at interface NSFoo
> + at end
> +
> +template<typename T>
> +void f(T t) {
> +  g(t);
> +}
> +
> +void g(NSFoo*);
> +
> +void test(NSFoo *foo) {
> +  f(foo);
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list