Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / temp / temp.spec / temp.explicit / p1.cpp
blob5a77d27d5ab68fb5fc182b61cba3570a20baf251
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
5 struct C { };
7 template<typename T>
8 struct X0 {
9 T value; // expected-error{{incomplete}}
12 // Explicitly instantiate a class template specialization
13 template struct X0<int>;
14 template struct X0<void>; // expected-note{{instantiation}}
16 // Explicitly instantiate a function template specialization
17 template<typename T>
18 void f0(T t) {
19 ++t; // expected-error{{cannot increment}}
22 template void f0(int);
23 template void f0<long>(long);
24 template void f0<>(unsigned);
25 template void f0(int C::*); // expected-note{{instantiation}}
27 // Explicitly instantiate a member template specialization
28 template<typename T>
29 struct X1 {
30 template<typename U>
31 struct Inner {
32 T member1;
33 U member2; // expected-error{{incomplete}}
36 template<typename U>
37 void f(T& t, U u) {
38 t = u; // expected-error{{incompatible}}
42 template struct X1<int>::Inner<float>;
43 template struct X1<int>::Inner<double>;
44 template struct X1<int>::Inner<void>; // expected-note{{instantiation}}
46 template void X1<int>::f(int&, float);
47 template void X1<int>::f<long>(int&, long);
48 template void X1<int>::f<>(int&, double);
49 template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}}
51 // Explicitly instantiate members of a class template
52 struct Incomplete; // expected-note{{forward declaration}}
53 struct 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}}
60 template<typename T, typename U>
61 struct X2 {
62 void f(T &t, U u) {
63 t = u; // expected-error{{incompatible}}
66 struct Inner {
67 T member1;
68 U member2; // expected-error{{incomplete}}
71 static T static_member1;
72 static U static_member2;
75 template<typename T, typename U>
76 T X2<T, U>::static_member1 = 17; // expected-error{{cannot initialize}}
78 template<typename T, typename U>
79 U X2<T, U>::static_member2; // expected-error{{no matching}}
81 template void X2<int, float>::f(int &, float);
82 template void X2<int, float>::f(int &, double); // expected-error{{does not refer}}
83 template void X2<int, int*>::f(int&, int*); // expected-note{{instantiation}}
85 template struct X2<int, float>::Inner;
86 template struct X2<int, Incomplete>::Inner; // expected-note{{instantiation}}
88 template int X2<int, float>::static_member1;
89 template int* X2<int*, float>::static_member1; // expected-note{{instantiation}}
90 template
91 NonDefaultConstructible X2<NonDefaultConstructible, int>::static_member1;
93 template
94 NonDefaultConstructible X2<int, NonDefaultConstructible>::static_member2; // expected-note{{instantiation}}