John McCall | c000834 | 2010-05-13 07:48:05 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | @class NSString; |
| 4 | |
| 5 | // Reduced from WebKit. |
| 6 | namespace 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 | } |
John McCall | 5d7c29a | 2010-05-13 08:39:13 +0000 | [diff] [blame] | 24 | |
| 25 | void test(id S) { |
| 26 | RetainPtr<id> ptr(S); |
| 27 | } |
John McCall | c000834 | 2010-05-13 07:48:05 +0000 | [diff] [blame] | 28 | } |
John McCall | c12c5bb | 2010-05-15 11:32:37 +0000 | [diff] [blame] | 29 | |
| 30 | @class Test1Class; |
| 31 | @protocol Test1Protocol; |
| 32 | namespace 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 | } |
John McCall | db0bc47 | 2010-08-05 05:30:45 +0000 | [diff] [blame] | 59 | |
| 60 | namespace test2 { |
| 61 | template <typename T> void foo(const T* t) {} |
| 62 | void test(id x) { |
| 63 | foo(x); |
| 64 | } |
| 65 | } |