Douglas Gregor | 52604ab | 2009-09-11 21:19:12 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Douglas Gregor | 45f9655 | 2009-09-04 06:33:52 +0000 | [diff] [blame] | 2 | |
| 3 | template<typename T> |
| 4 | class X0 { |
| 5 | public: |
| 6 | void f(T t); |
Douglas Gregor | 678119a | 2009-09-11 20:35:49 +0000 | [diff] [blame] | 7 | |
| 8 | struct Inner { |
| 9 | void g(T t); |
| 10 | }; |
Douglas Gregor | 45f9655 | 2009-09-04 06:33:52 +0000 | [diff] [blame] | 11 | }; |
| 12 | |
| 13 | template<typename T> |
| 14 | void X0<T>::f(T t) { |
Douglas Gregor | 52604ab | 2009-09-11 21:19:12 +0000 | [diff] [blame] | 15 | t = 17; // expected-error{{incompatible}} |
Douglas Gregor | 45f9655 | 2009-09-04 06:33:52 +0000 | [diff] [blame] | 16 | } |
| 17 | |
Douglas Gregor | 45f9655 | 2009-09-04 06:33:52 +0000 | [diff] [blame] | 18 | extern template class X0<int>; |
Douglas Gregor | 678119a | 2009-09-11 20:35:49 +0000 | [diff] [blame] | 19 | |
| 20 | extern template class X0<int*>; |
| 21 | |
| 22 | template<typename T> |
| 23 | void X0<T>::Inner::g(T t) { |
Douglas Gregor | 52604ab | 2009-09-11 21:19:12 +0000 | [diff] [blame] | 24 | t = 17; // expected-error{{incompatible}} |
Douglas Gregor | 678119a | 2009-09-11 20:35:49 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | void test_intptr(X0<int*> xi, X0<int*>::Inner xii) { |
| 28 | xi.f(0); |
| 29 | xii.g(0); |
| 30 | } |
Douglas Gregor | 52604ab | 2009-09-11 21:19:12 +0000 | [diff] [blame] | 31 | |
| 32 | // FIXME: we would like the notes to point to the explicit instantiation at the |
| 33 | // bottom. |
Douglas Gregor | 2db3232 | 2009-10-07 23:56:10 +0000 | [diff] [blame] | 34 | extern template class X0<long*>; // expected-note 2{{instantiation}} |
Douglas Gregor | 52604ab | 2009-09-11 21:19:12 +0000 | [diff] [blame] | 35 | |
| 36 | void test_longptr(X0<long*> xl, X0<long*>::Inner xli) { |
| 37 | xl.f(0); |
Douglas Gregor | 2db3232 | 2009-10-07 23:56:10 +0000 | [diff] [blame] | 38 | xli.g(0); |
Douglas Gregor | 52604ab | 2009-09-11 21:19:12 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | template class X0<long*>; |
Douglas Gregor | 4831682 | 2009-09-29 14:38:03 +0000 | [diff] [blame] | 42 | |
| 43 | template<typename T> |
| 44 | class X1 { |
| 45 | public: |
| 46 | void f(T t) { t += 2; } |
| 47 | |
| 48 | void g(T t); |
| 49 | }; |
| 50 | |
| 51 | template<typename T> |
| 52 | void X1<T>::g(T t) { |
| 53 | t += 2; |
| 54 | } |
| 55 | |
| 56 | extern template class X1<void*>; |
| 57 | |
| 58 | void g_X1(X1<void*> x1, void *ptr) { |
| 59 | x1.g(ptr); |
| 60 | } |
| 61 | |
| 62 | extern template void X1<const void*>::g(const void*); |
| 63 | |
| 64 | void g_X1_2(X1<const void *> x1, const void *ptr) { |
Douglas Gregor | e9374d5 | 2009-10-08 01:19:17 +0000 | [diff] [blame^] | 65 | x1.g(ptr); |
Douglas Gregor | 4831682 | 2009-09-29 14:38:03 +0000 | [diff] [blame] | 66 | } |