66 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3@class NSString;4 5// Reduced from WebKit.6namespace test0 {7 template <typename T> struct RemovePointer {8 typedef T Type;9 };10 11 template <typename T> struct RemovePointer<T*> {12 typedef T Type;13 };14 15 template <typename T> struct RetainPtr {16 typedef typename RemovePointer<T>::Type ValueType;17 typedef ValueType* PtrType;18 RetainPtr(PtrType ptr);19 };20 21 void test(NSString *S) {22 RetainPtr<NSString*> ptr(S);23 }24 25 void test(id S) {26 RetainPtr<id> ptr(S);27 }28}29 30@class Test1Class;31@protocol Test1Protocol;32namespace test1 {33 template <typename T> struct RemovePointer {34 typedef T type;35 };36 template <typename T> struct RemovePointer<T*> {37 typedef T type;38 };39 template <typename A, typename B> struct is_same {};40 template <typename A> struct is_same<A,A> {41 static void foo();42 };43 template <typename T> struct tester {44 void test() {45 is_same<T, typename RemovePointer<T>::type*>::foo(); // expected-error 2 {{no member named 'foo'}}46 }47 };48 49 template struct tester<id>;50 template struct tester<id<Test1Protocol> >;51 template struct tester<Class>;52 template struct tester<Class<Test1Protocol> >;53 template struct tester<Test1Class*>;54 template struct tester<Test1Class<Test1Protocol>*>;55 56 template struct tester<Test1Class>; // expected-note {{in instantiation}}57 template struct tester<Test1Class<Test1Protocol> >; // expected-note {{in instantiation}}58}59 60namespace test2 {61 template <typename T> void foo(const T* t) {}62 void test(id x) {63 foo(x);64 }65}66