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