1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3template void *; // expected-error{{expected unqualified-id}}
4
5template typedef void f0; // expected-error{{explicit instantiation of typedef}}
6
7int v0; // expected-note{{refers here}}
8template int v0; // expected-error{{does not refer}}
9
10template<typename T>
11struct 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*) { return T(); }
18
19  template<typename U>
20  T f0(T, U) { return T(); }
21};
22
23template<typename T>
24T X0<T>::value; // expected-error{{no matching constructor}}
25
26template int X0<int>::value;
27
28struct NotDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor)}}
29  NotDefaultConstructible(int); // expected-note{{candidate constructor}}
30};
31
32template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}}
33
34template int X0<int>::f0(int);
35template int* X0<int>::f0(int*, int*);
36template int X0<int>::f0(int, float);
37
38template int X0<int>::f0(int) const; // expected-error{{does not refer}}
39template int* X0<int>::f0(int*, float*); // expected-error{{does not refer}}
40
41struct X1 { };
42typedef int X1::*MemPtr;
43
44template MemPtr X0<MemPtr>::f0(MemPtr); // expected-note{{requested here}}
45
46struct X2 {
47  int f0(int); // expected-note{{refers here}}
48
49  template<typename T> T f1(T) { return T(); }
50  template<typename T> T* f1(T*) { return 0; }
51
52  template<typename T, typename U> void f2(T, U*) { } // expected-note{{candidate}}
53  template<typename T, typename U> void f2(T*, U) { } // expected-note{{candidate}}
54};
55
56template int X2::f0(int); // expected-error{{not an instantiation}}
57
58template int *X2::f1(int *); // okay
59
60template void X2::f2(int *, int *); // expected-error{{ambiguous}}
61
62
63template<typename T> void print_type() { }
64
65template void print_type<int>();
66template void print_type<float>();
67
68template<typename T> void print_type(T*) { }
69
70template void print_type(int*);
71template void print_type<int>(float*); // expected-error{{does not refer}}
72
73void print_type(double*);
74template void print_type<double>(double*);
75
76// PR5069
77template<int I> void foo0 (int (&)[I + 1]) { }
78template void foo0<2> (int (&)[3]);
79
80namespace explicit_instantiation_after_implicit_instantiation {
81  template <int I> struct X0 { static int x; };
82  template <int I> int X0<I>::x;
83  void test1() { (void)&X0<1>::x; }
84  template struct X0<1>;
85}
86
87template<typename> struct X3 { };
88inline template struct X3<int>; // expected-warning{{ignoring 'inline' keyword on explicit template instantiation}}
89static template struct X3<float>; // expected-warning{{ignoring 'static' keyword on explicit template instantiation}}
90
91namespace PR7622 {
92  template<typename,typename=int>
93  struct basic_streambuf;
94
95  template<typename,typename>
96  struct basic_streambuf{friend bob<>()}; // expected-error{{unknown type name 'bob'}} \
97  // expected-error{{ expected member name or ';' after declaration specifiers}}
98  template struct basic_streambuf<int>;
99}
100