18fbe78f6SDaniel Dunbar // RUN: %clang_cc1 -fsyntax-only -verify %s
2*e7cbb3edSCharles Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3*e7cbb3edSCharles Li // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
43c74d41dSDouglas Gregor
53c74d41dSDouglas Gregor struct C { };
63c74d41dSDouglas Gregor
73c74d41dSDouglas Gregor template<typename T>
83c74d41dSDouglas Gregor struct X0 {
93c74d41dSDouglas Gregor T value; // expected-error{{incomplete}}
103c74d41dSDouglas Gregor };
113c74d41dSDouglas Gregor
123c74d41dSDouglas Gregor // Explicitly instantiate a class template specialization
133c74d41dSDouglas Gregor template struct X0<int>;
143c74d41dSDouglas Gregor template struct X0<void>; // expected-note{{instantiation}}
153c74d41dSDouglas Gregor
163c74d41dSDouglas Gregor // Explicitly instantiate a function template specialization
173c74d41dSDouglas Gregor template<typename T>
f0(T t)183c74d41dSDouglas Gregor void f0(T t) {
19906db8a5SDouglas Gregor ++t; // expected-error{{cannot increment}}
203c74d41dSDouglas Gregor }
213c74d41dSDouglas Gregor
223c74d41dSDouglas Gregor template void f0(int);
233c74d41dSDouglas Gregor template void f0<long>(long);
243c74d41dSDouglas Gregor template void f0<>(unsigned);
253c74d41dSDouglas Gregor template void f0(int C::*); // expected-note{{instantiation}}
263c74d41dSDouglas Gregor
273c74d41dSDouglas Gregor // Explicitly instantiate a member template specialization
283c74d41dSDouglas Gregor template<typename T>
293c74d41dSDouglas Gregor struct X1 {
303c74d41dSDouglas Gregor template<typename U>
313c74d41dSDouglas Gregor struct Inner {
323c74d41dSDouglas Gregor T member1;
333c74d41dSDouglas Gregor U member2; // expected-error{{incomplete}}
343c74d41dSDouglas Gregor };
353c74d41dSDouglas Gregor
363c74d41dSDouglas Gregor template<typename U>
fX1373c74d41dSDouglas Gregor void f(T& t, U u) {
383c74d41dSDouglas Gregor t = u; // expected-error{{incompatible}}
393c74d41dSDouglas Gregor }
403c74d41dSDouglas Gregor };
413c74d41dSDouglas Gregor
423c74d41dSDouglas Gregor template struct X1<int>::Inner<float>;
433c74d41dSDouglas Gregor template struct X1<int>::Inner<double>;
443c74d41dSDouglas Gregor template struct X1<int>::Inner<void>; // expected-note{{instantiation}}
453c74d41dSDouglas Gregor
463c74d41dSDouglas Gregor template void X1<int>::f(int&, float);
473c74d41dSDouglas Gregor template void X1<int>::f<long>(int&, long);
483c74d41dSDouglas Gregor template void X1<int>::f<>(int&, double);
493c74d41dSDouglas Gregor template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}}
503c74d41dSDouglas Gregor
513c74d41dSDouglas Gregor // Explicitly instantiate members of a class template
523c74d41dSDouglas Gregor struct Incomplete; // expected-note{{forward declaration}}
53e1ac8d17SJohn McCall struct NonDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
54*e7cbb3edSCharles Li #if __cplusplus >= 201103L // C++11 or later
55*e7cbb3edSCharles Li // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
56*e7cbb3edSCharles Li #endif
57fd0b2f8fSJohn McCall NonDefaultConstructible(int); // expected-note{{candidate constructor}}
583c74d41dSDouglas Gregor };
593c74d41dSDouglas Gregor
603c74d41dSDouglas Gregor template<typename T, typename U>
613c74d41dSDouglas Gregor struct X2 {
fX2623c74d41dSDouglas Gregor void f(T &t, U u) {
633c74d41dSDouglas Gregor t = u; // expected-error{{incompatible}}
643c74d41dSDouglas Gregor }
653c74d41dSDouglas Gregor
663c74d41dSDouglas Gregor struct Inner {
673c74d41dSDouglas Gregor T member1;
683c74d41dSDouglas Gregor U member2; // expected-error{{incomplete}}
693c74d41dSDouglas Gregor };
703c74d41dSDouglas Gregor
713c74d41dSDouglas Gregor static T static_member1;
723c74d41dSDouglas Gregor static U static_member2;
733c74d41dSDouglas Gregor };
743c74d41dSDouglas Gregor
753c74d41dSDouglas Gregor template<typename T, typename U>
76463e523aSEli Friedman T X2<T, U>::static_member1 = 17; // expected-error{{cannot initialize}}
773c74d41dSDouglas Gregor
783c74d41dSDouglas Gregor template<typename T, typename U>
793c74d41dSDouglas Gregor U X2<T, U>::static_member2; // expected-error{{no matching}}
803c74d41dSDouglas Gregor
813c74d41dSDouglas Gregor template void X2<int, float>::f(int &, float);
823c74d41dSDouglas Gregor template void X2<int, float>::f(int &, double); // expected-error{{does not refer}}
833c74d41dSDouglas Gregor template void X2<int, int*>::f(int&, int*); // expected-note{{instantiation}}
843c74d41dSDouglas Gregor
853c74d41dSDouglas Gregor template struct X2<int, float>::Inner;
863c74d41dSDouglas Gregor template struct X2<int, Incomplete>::Inner; // expected-note{{instantiation}}
873c74d41dSDouglas Gregor
883c74d41dSDouglas Gregor template int X2<int, float>::static_member1;
893c74d41dSDouglas Gregor template int* X2<int*, float>::static_member1; // expected-note{{instantiation}}
903c74d41dSDouglas Gregor template
913c74d41dSDouglas Gregor NonDefaultConstructible X2<NonDefaultConstructible, int>::static_member1;
923c74d41dSDouglas Gregor
933c74d41dSDouglas Gregor template
943c74d41dSDouglas Gregor NonDefaultConstructible X2<int, NonDefaultConstructible>::static_member2; // expected-note{{instantiation}}
95