blob: 28fda1a11e6bb94ff852b466d70490eab472451f [file] [log] [blame]
Douglas Gregor52604ab2009-09-11 21:19:12 +00001// RUN: clang-cc -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
32// FIXME: we would like the notes to point to the explicit instantiation at the
33// bottom.
Douglas Gregor2db32322009-10-07 23:56:10 +000034extern template class X0<long*>; // expected-note 2{{instantiation}}
Douglas Gregor52604ab2009-09-11 21:19:12 +000035
36void test_longptr(X0<long*> xl, X0<long*>::Inner xli) {
37 xl.f(0);
Douglas Gregor2db32322009-10-07 23:56:10 +000038 xli.g(0);
Douglas Gregor52604ab2009-09-11 21:19:12 +000039}
40
41template class X0<long*>;
Douglas Gregor48316822009-09-29 14:38:03 +000042
43template<typename T>
44class X1 {
45public:
46 void f(T t) { t += 2; }
47
48 void g(T t);
49};
50
51template<typename T>
52void X1<T>::g(T t) {
53 t += 2;
54}
55
56extern template class X1<void*>;
57
58void g_X1(X1<void*> x1, void *ptr) {
59 x1.g(ptr);
60}
61
62extern template void X1<const void*>::g(const void*);
63
64void g_X1_2(X1<const void *> x1, const void *ptr) {
Douglas Gregore9374d52009-10-08 01:19:17 +000065 x1.g(ptr);
Douglas Gregor48316822009-09-29 14:38:03 +000066}