1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4
5struct C { };
6
7template<typename T>
8struct X0 {
9  T value; // expected-error{{incomplete}}
10};
11
12// Explicitly instantiate a class template specialization
13template struct X0<int>;
14template struct X0<void>; // expected-note{{instantiation}}
15
16// Explicitly instantiate a function template specialization
17template<typename T>
18void f0(T t) {
19  ++t; // expected-error{{cannot increment}}
20}
21
22template void f0(int);
23template void f0<long>(long);
24template void f0<>(unsigned);
25template void f0(int C::*); // expected-note{{instantiation}}
26
27// Explicitly instantiate a member template specialization
28template<typename T>
29struct X1 {
30  template<typename U>
31  struct Inner {
32    T member1;
33    U member2; // expected-error{{incomplete}}
34  };
35
36  template<typename U>
37  void f(T& t, U u) {
38    t = u; // expected-error{{incompatible}}
39  }
40};
41
42template struct X1<int>::Inner<float>;
43template struct X1<int>::Inner<double>;
44template struct X1<int>::Inner<void>; // expected-note{{instantiation}}
45
46template void X1<int>::f(int&, float);
47template void X1<int>::f<long>(int&, long);
48template void X1<int>::f<>(int&, double);
49template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}}
50
51// Explicitly instantiate members of a class template
52struct Incomplete; // expected-note{{forward declaration}}
53struct NonDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
54#if __cplusplus >= 201103L // C++11 or later
55// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
56#endif
57  NonDefaultConstructible(int); // expected-note{{candidate constructor}}
58};
59
60template<typename T, typename U>
61struct X2 {
62  void f(T &t, U u) {
63    t = u; // expected-error{{incompatible}}
64  }
65
66  struct Inner {
67    T member1;
68    U member2; // expected-error{{incomplete}}
69  };
70
71  static T static_member1;
72  static U static_member2;
73};
74
75template<typename T, typename U>
76T X2<T, U>::static_member1 = 17; // expected-error{{cannot initialize}}
77
78template<typename T, typename U>
79U X2<T, U>::static_member2; // expected-error{{no matching}}
80
81template void X2<int, float>::f(int &, float);
82template void X2<int, float>::f(int &, double); // expected-error{{does not refer}}
83template void X2<int, int*>::f(int&, int*); // expected-note{{instantiation}}
84
85template struct X2<int, float>::Inner;
86template struct X2<int, Incomplete>::Inner; // expected-note{{instantiation}}
87
88template int X2<int, float>::static_member1;
89template int* X2<int*, float>::static_member1; // expected-note{{instantiation}}
90template
91  NonDefaultConstructible X2<NonDefaultConstructible, int>::static_member1;
92
93template
94  NonDefaultConstructible X2<int, NonDefaultConstructible>::static_member2; // expected-note{{instantiation}}
95