1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -Wundefined-func-template %s
3 template <class T> struct C1 {
4 static char s_var_1; // expected-note{{forward declaration of template entity is here}}
5 static char s_var_2; // expected-note{{forward declaration of template entity is here}}
6 static void s_func_1(); // expected-note{{forward declaration of template entity is here}}
7 static void s_func_2(); // expected-note{{forward declaration of template entity is here}}
8 void meth_1(); // expected-note2{{forward declaration of template entity is here}}
10 template <class T1> static char s_tvar_2; // expected-note{{forward declaration of template entity is here}}
11 template <class T1> static void s_tfunc_2(); // expected-note{{forward declaration of template entity is here}}
12 template<typename T1> struct C2 {
13 static char s_var_2; // expected-note{{forward declaration of template entity is here}}
14 static void s_func_2(); // expected-note{{forward declaration of template entity is here}}
15 void meth_2(); // expected-note{{forward declaration of template entity is here}}
16 template <class T2> static char s_tvar_2; // expected-note{{forward declaration of template entity is here}}
17 template <class T2> void tmeth_2(); // expected-note{{forward declaration of template entity is here}}
21 extern template char C1<int>::s_var_2;
22 extern template void C1<int>::s_func_2();
23 extern template void C1<int>::meth_2();
24 extern template char C1<int>::s_tvar_2<char>;
25 extern template void C1<int>::s_tfunc_2<char>();
26 extern template void C1<int>::C2<long>::s_var_2;
27 extern template void C1<int>::C2<long>::s_func_2();
28 extern template void C1<int>::C2<long>::meth_2();
29 extern template char C1<int>::C2<long>::s_tvar_2<char>;
30 extern template void C1<int>::C2<long>::tmeth_2<char>();
33 return C1<int>::s_var_2;
37 return C1<int>::s_var_1; // expected-warning{{instantiation of variable 'C1<int>::s_var_1' required here, but no definition is available}}
38 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::s_var_1' is explicitly instantiated in another translation unit}}
42 return C1<char>::s_var_2; // expected-warning{{instantiation of variable 'C1<char>::s_var_2' required here, but no definition is available}}
43 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<char>::s_var_2' is explicitly instantiated in another translation unit}}
47 C1<int>::s_func_1(); // expected-warning{{instantiation of function 'C1<int>::s_func_1' required here, but no definition is available}}
48 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::s_func_1' is explicitly instantiated in another translation unit}}
56 C1<char>::s_func_2(); // expected-warning{{instantiation of function 'C1<char>::s_func_2' required here, but no definition is available}}
57 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<char>::s_func_2' is explicitly instantiated in another translation unit}}
60 void func_07(C1<int> *x) {
61 x->meth_1(); // expected-warning{{instantiation of function 'C1<int>::meth_1' required here, but no definition is available}}
62 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::meth_1' is explicitly instantiated in another translation unit}}
65 void func_08(C1<int> *x) {
69 void func_09(C1<char> *x) {
70 x->meth_1(); // expected-warning{{instantiation of function 'C1<char>::meth_1' required here, but no definition is available}}
71 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<char>::meth_1' is explicitly instantiated in another translation unit}}
75 return C1<int>::s_tvar_2<char>;
79 return C1<int>::s_tvar_2<long>; // expected-warning{{instantiation of variable 'C1<int>::s_tvar_2<long>' required here, but no definition is available}}
80 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::s_tvar_2<long>' is explicitly instantiated in another translation unit}}
84 C1<int>::s_tfunc_2<char>();
88 C1<int>::s_tfunc_2<long>(); // expected-warning{{instantiation of function 'C1<int>::s_tfunc_2<long>' required here, but no definition is available}}
89 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::s_tfunc_2<long>' is explicitly instantiated in another translation unit}}
93 return C1<int>::C2<long>::s_var_2;
97 return C1<int>::C2<char>::s_var_2; //expected-warning {{instantiation of variable 'C1<int>::C2<char>::s_var_2' required here, but no definition is available}}
98 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::C2<char>::s_var_2' is explicitly instantiated in another translation unit}}
102 C1<int>::C2<long>::s_func_2();
106 C1<int>::C2<char>::s_func_2(); // expected-warning{{instantiation of function 'C1<int>::C2<char>::s_func_2' required here, but no definition is available}}
107 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::C2<char>::s_func_2' is explicitly instantiated in another translation unit}}
110 void func_18(C1<int>::C2<long> *x) {
114 void func_19(C1<int>::C2<char> *x) {
115 x->meth_2(); // expected-warning{{instantiation of function 'C1<int>::C2<char>::meth_2' required here, but no definition is available}}
116 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::C2<char>::meth_2' is explicitly instantiated in another translation unit}}
120 return C1<int>::C2<long>::s_tvar_2<char>;
124 return C1<int>::C2<long>::s_tvar_2<long>; // expected-warning{{instantiation of variable 'C1<int>::C2<long>::s_tvar_2<long>' required here, but no definition is available}}
125 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::C2<long>::s_tvar_2<long>' is explicitly instantiated in another translation unit}}
128 void func_22(C1<int>::C2<long> *x) {
132 void func_23(C1<int>::C2<long> *x) {
133 x->tmeth_2<int>(); // expected-warning{{instantiation of function 'C1<int>::C2<long>::tmeth_2<int>' required here, but no definition is available}}
134 // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1<int>::C2<long>::tmeth_2<int>' is explicitly instantiated in another translation unit}}
138 template <typename T> struct X {
140 operator int() { return 0; }
142 void h(X<int> x) { g(x); } // no warning for use of 'g' despite the declaration having been instantiated from a template