blob: 220f36863bab7c39e17d784f6378186363f87fff [file] [log] [blame]
John McCallc0008342010-05-13 07:48:05 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
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 }
John McCall5d7c29a2010-05-13 08:39:13 +000024
25 void test(id S) {
26 RetainPtr<id> ptr(S);
27 }
John McCallc0008342010-05-13 07:48:05 +000028}
John McCallc12c5bb2010-05-15 11:32:37 +000029
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}
John McCalldb0bc472010-08-05 05:30:45 +000059
60namespace test2 {
61 template <typename T> void foo(const T* t) {}
62 void test(id x) {
63 foo(x);
64 }
65}