// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -Wundefined-func-template %s template struct C1 { static char s_var_1; // expected-note{{forward declaration of template entity is here}} static char s_var_2; // expected-note{{forward declaration of template entity is here}} static void s_func_1(); // expected-note{{forward declaration of template entity is here}} static void s_func_2(); // expected-note{{forward declaration of template entity is here}} void meth_1(); // expected-note2{{forward declaration of template entity is here}} void meth_2(); template static char s_tvar_2; // expected-note{{forward declaration of template entity is here}} template static void s_tfunc_2(); // expected-note{{forward declaration of template entity is here}} template struct C2 { static char s_var_2; // expected-note{{forward declaration of template entity is here}} static void s_func_2(); // expected-note{{forward declaration of template entity is here}} void meth_2(); // expected-note{{forward declaration of template entity is here}} template static char s_tvar_2; // expected-note{{forward declaration of template entity is here}} template void tmeth_2(); // expected-note{{forward declaration of template entity is here}} }; }; extern template char C1::s_var_2; extern template void C1::s_func_2(); extern template void C1::meth_2(); extern template char C1::s_tvar_2; extern template void C1::s_tfunc_2(); extern template void C1::C2::s_var_2; extern template void C1::C2::s_func_2(); extern template void C1::C2::meth_2(); extern template char C1::C2::s_tvar_2; extern template void C1::C2::tmeth_2(); char func_01() { return C1::s_var_2; } char func_02() { return C1::s_var_1; // expected-warning{{instantiation of variable 'C1::s_var_1' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_var_1' is explicitly instantiated in another translation unit}} } char func_03() { return C1::s_var_2; // expected-warning{{instantiation of variable 'C1::s_var_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_var_2' is explicitly instantiated in another translation unit}} } void func_04() { C1::s_func_1(); // expected-warning{{instantiation of function 'C1::s_func_1' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_func_1' is explicitly instantiated in another translation unit}} } void func_05() { C1::s_func_2(); } void func_06() { C1::s_func_2(); // expected-warning{{instantiation of function 'C1::s_func_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_func_2' is explicitly instantiated in another translation unit}} } void func_07(C1 *x) { x->meth_1(); // expected-warning{{instantiation of function 'C1::meth_1' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::meth_1' is explicitly instantiated in another translation unit}} } void func_08(C1 *x) { x->meth_2(); } void func_09(C1 *x) { x->meth_1(); // expected-warning{{instantiation of function 'C1::meth_1' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::meth_1' is explicitly instantiated in another translation unit}} } char func_10() { return C1::s_tvar_2; } char func_11() { return C1::s_tvar_2; // expected-warning{{instantiation of variable 'C1::s_tvar_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_tvar_2' is explicitly instantiated in another translation unit}} } void func_12() { C1::s_tfunc_2(); } void func_13() { C1::s_tfunc_2(); // expected-warning{{instantiation of function 'C1::s_tfunc_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_tfunc_2' is explicitly instantiated in another translation unit}} } char func_14() { return C1::C2::s_var_2; } char func_15() { return C1::C2::s_var_2; //expected-warning {{instantiation of variable 'C1::C2::s_var_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::C2::s_var_2' is explicitly instantiated in another translation unit}} } void func_16() { C1::C2::s_func_2(); } void func_17() { C1::C2::s_func_2(); // expected-warning{{instantiation of function 'C1::C2::s_func_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::C2::s_func_2' is explicitly instantiated in another translation unit}} } void func_18(C1::C2 *x) { x->meth_2(); } void func_19(C1::C2 *x) { x->meth_2(); // expected-warning{{instantiation of function 'C1::C2::meth_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::C2::meth_2' is explicitly instantiated in another translation unit}} } char func_20() { return C1::C2::s_tvar_2; } char func_21() { return C1::C2::s_tvar_2; // expected-warning{{instantiation of variable 'C1::C2::s_tvar_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::C2::s_tvar_2' is explicitly instantiated in another translation unit}} } void func_22(C1::C2 *x) { x->tmeth_2(); } void func_23(C1::C2 *x) { x->tmeth_2(); // expected-warning{{instantiation of function 'C1::C2::tmeth_2' required here, but no definition is available}} // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::C2::tmeth_2' is explicitly instantiated in another translation unit}} } namespace test_24 { template struct X { friend void g(int); operator int() { return 0; } }; void h(X x) { g(x); } // no warning for use of 'g' despite the declaration having been instantiated from a template } int main() { return 0; }