2009-09-26 02:43:00 +08:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify %s
|
|
|
|
|
|
|
|
template void *; // expected-error{{expected unqualified-id}}
|
|
|
|
|
|
|
|
template typedef void f0; // expected-error{{explicit instantiation of typedef}}
|
|
|
|
|
|
|
|
int v0; // expected-note{{refers here}}
|
|
|
|
template int v0; // expected-error{{does not refer}}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct X0 {
|
|
|
|
static T value;
|
|
|
|
|
|
|
|
T f0(T x) {
|
|
|
|
return x + 1; // expected-error{{invalid operands}}
|
|
|
|
}
|
2009-10-15 07:41:34 +08:00
|
|
|
T* f0(T*, T*) { return T(); }
|
2009-09-26 02:43:00 +08:00
|
|
|
|
|
|
|
template<typename U>
|
2009-10-15 07:41:34 +08:00
|
|
|
T f0(T, U) { return T(); }
|
2009-09-26 02:43:00 +08:00
|
|
|
};
|
|
|
|
|
2009-10-15 07:41:34 +08:00
|
|
|
template<typename T>
|
|
|
|
T X0<T>::value; // expected-error{{no matching constructor}}
|
|
|
|
|
2009-09-26 02:43:00 +08:00
|
|
|
template int X0<int>::value;
|
|
|
|
|
|
|
|
struct NotDefaultConstructible {
|
|
|
|
NotDefaultConstructible(int);
|
|
|
|
};
|
|
|
|
|
2009-10-15 07:41:34 +08:00
|
|
|
template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}}
|
2009-09-26 02:43:00 +08:00
|
|
|
|
|
|
|
template int X0<int>::f0(int);
|
|
|
|
template int* X0<int>::f0(int*, int*);
|
|
|
|
template int X0<int>::f0(int, float);
|
|
|
|
|
|
|
|
template int X0<int>::f0(int) const; // expected-error{{does not refer}}
|
|
|
|
template int* X0<int>::f0(int*, float*); // expected-error{{does not refer}}
|
|
|
|
|
|
|
|
struct X1 { };
|
|
|
|
typedef int X1::*MemPtr;
|
|
|
|
|
|
|
|
template MemPtr X0<MemPtr>::f0(MemPtr); // expected-note{{requested here}}
|
|
|
|
|
|
|
|
struct X2 {
|
|
|
|
int f0(int); // expected-note{{refers here}}
|
|
|
|
|
2009-10-15 07:41:34 +08:00
|
|
|
template<typename T> T f1(T) { return T(); }
|
|
|
|
template<typename T> T* f1(T*) { return 0; }
|
2009-09-26 02:43:00 +08:00
|
|
|
|
2009-10-15 07:41:34 +08:00
|
|
|
template<typename T, typename U> void f2(T, U*) { } // expected-note{{candidate}}
|
|
|
|
template<typename T, typename U> void f2(T*, U) { } // expected-note{{candidate}}
|
2009-09-26 02:43:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template int X2::f0(int); // expected-error{{not an instantiation}}
|
|
|
|
|
|
|
|
template int *X2::f1(int *); // okay
|
|
|
|
|
|
|
|
template void X2::f2(int *, int *); // expected-error{{ambiguous}}
|
2009-09-26 05:45:23 +08:00
|
|
|
|
|
|
|
|
2009-10-15 07:41:34 +08:00
|
|
|
template<typename T> void print_type() { }
|
2009-09-26 05:45:23 +08:00
|
|
|
|
|
|
|
template void print_type<int>();
|
|
|
|
template void print_type<float>();
|
|
|
|
|
2009-10-15 07:41:34 +08:00
|
|
|
template<typename T> void print_type(T*) { }
|
2009-09-26 05:45:23 +08:00
|
|
|
|
|
|
|
template void print_type(int*);
|
|
|
|
template void print_type<int>(float*); // expected-error{{does not refer}}
|
|
|
|
|
|
|
|
void print_type(double*);
|
|
|
|
template void print_type<double>(double*);
|
2009-10-02 07:51:25 +08:00
|
|
|
|
|
|
|
// PR5069
|
|
|
|
template<int I> void foo0 (int (&)[I + 1]) { }
|
|
|
|
template void foo0<2> (int (&)[3]);
|