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