Douglas Gregor | d5a423b | 2009-09-25 18:43:00 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | template void *; // expected-error{{expected unqualified-id}} |
| 4 | |
| 5 | template typedef void f0; // expected-error{{explicit instantiation of typedef}} |
| 6 | |
| 7 | int v0; // expected-note{{refers here}} |
| 8 | template int v0; // expected-error{{does not refer}} |
| 9 | |
| 10 | template<typename T> |
| 11 | struct X0 { |
| 12 | static T value; |
| 13 | |
| 14 | T f0(T x) { |
| 15 | return x + 1; // expected-error{{invalid operands}} |
| 16 | } |
| 17 | T* f0(T*, T*); |
| 18 | |
| 19 | template<typename U> |
| 20 | T f0(T, U); |
| 21 | }; |
| 22 | |
| 23 | template int X0<int>::value; |
| 24 | |
| 25 | struct NotDefaultConstructible { |
| 26 | NotDefaultConstructible(int); |
| 27 | }; |
| 28 | |
| 29 | template NotDefaultConstructible X0<NotDefaultConstructible>::value; |
| 30 | |
| 31 | template int X0<int>::f0(int); |
| 32 | template int* X0<int>::f0(int*, int*); |
| 33 | template int X0<int>::f0(int, float); |
| 34 | |
| 35 | template int X0<int>::f0(int) const; // expected-error{{does not refer}} |
| 36 | template int* X0<int>::f0(int*, float*); // expected-error{{does not refer}} |
| 37 | |
| 38 | struct X1 { }; |
| 39 | typedef int X1::*MemPtr; |
| 40 | |
| 41 | template MemPtr X0<MemPtr>::f0(MemPtr); // expected-note{{requested here}} |
| 42 | |
| 43 | struct X2 { |
| 44 | int f0(int); // expected-note{{refers here}} |
| 45 | |
| 46 | template<typename T> T f1(T); |
| 47 | template<typename T> T* f1(T*); |
| 48 | |
| 49 | template<typename T, typename U> void f2(T, U*); // expected-note{{candidate}} |
| 50 | template<typename T, typename U> void f2(T*, U); // expected-note{{candidate}} |
| 51 | }; |
| 52 | |
| 53 | template int X2::f0(int); // expected-error{{not an instantiation}} |
| 54 | |
| 55 | template int *X2::f1(int *); // okay |
| 56 | |
| 57 | template void X2::f2(int *, int *); // expected-error{{ambiguous}} |
Douglas Gregor | db422df | 2009-09-25 21:45:23 +0000 | [diff] [blame^] | 58 | |
| 59 | |
| 60 | template<typename T> void print_type(); |
| 61 | |
| 62 | template void print_type<int>(); |
| 63 | template void print_type<float>(); |
| 64 | |
| 65 | template<typename T> void print_type(T*); |
| 66 | |
| 67 | template void print_type(int*); |
| 68 | template void print_type<int>(float*); // expected-error{{does not refer}} |
| 69 | |
| 70 | void print_type(double*); |
| 71 | template void print_type<double>(double*); |