blob: eca64ed595ebfb1b317756b54d26158e41a47e90 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor45f96552009-09-04 06:33:52 +00002
3template<typename T>
4class X0 {
5public:
6 void f(T t);
Douglas Gregor678119a2009-09-11 20:35:49 +00007
8 struct Inner {
9 void g(T t);
10 };
Douglas Gregor45f96552009-09-04 06:33:52 +000011};
12
13template<typename T>
14void X0<T>::f(T t) {
Douglas Gregor52604ab2009-09-11 21:19:12 +000015 t = 17; // expected-error{{incompatible}}
Douglas Gregor45f96552009-09-04 06:33:52 +000016}
17
Douglas Gregor45f96552009-09-04 06:33:52 +000018extern template class X0<int>;
Douglas Gregor678119a2009-09-11 20:35:49 +000019
20extern template class X0<int*>;
21
22template<typename T>
23void X0<T>::Inner::g(T t) {
Douglas Gregor52604ab2009-09-11 21:19:12 +000024 t = 17; // expected-error{{incompatible}}
Douglas Gregor678119a2009-09-11 20:35:49 +000025}
26
27void test_intptr(X0<int*> xi, X0<int*>::Inner xii) {
28 xi.f(0);
29 xii.g(0);
30}
Douglas Gregor52604ab2009-09-11 21:19:12 +000031
Douglas Gregor89a5bea2009-10-15 22:53:21 +000032extern template class X0<long*>;
Douglas Gregor52604ab2009-09-11 21:19:12 +000033
34void test_longptr(X0<long*> xl, X0<long*>::Inner xli) {
35 xl.f(0);
Douglas Gregor2db32322009-10-07 23:56:10 +000036 xli.g(0);
Douglas Gregor52604ab2009-09-11 21:19:12 +000037}
38
Douglas Gregor89a5bea2009-10-15 22:53:21 +000039template class X0<long*>; // expected-note 2{{instantiation}}
Douglas Gregor48316822009-09-29 14:38:03 +000040
41template<typename T>
42class X1 {
43public:
44 void f(T t) { t += 2; }
45
46 void g(T t);
47};
48
49template<typename T>
50void X1<T>::g(T t) {
51 t += 2;
52}
53
54extern template class X1<void*>;
55
56void g_X1(X1<void*> x1, void *ptr) {
57 x1.g(ptr);
58}
59
60extern template void X1<const void*>::g(const void*);
61
62void g_X1_2(X1<const void *> x1, const void *ptr) {
Douglas Gregore9374d52009-10-08 01:19:17 +000063 x1.g(ptr);
Douglas Gregor48316822009-09-29 14:38:03 +000064}