// RUN: %clang_cc1 -std=c++20 -verify %s // Templates and partial and explicit specializations can't have C linkage. namespace extern_c_templates { template struct A { static int a; struct b; void c(); enum class d; template static int e; template struct f; template void g(); }; template int B; template void C(); extern "C" { // expected-note 1+{{begins here}} // templates template struct A; // expected-error {{templates must have C++ linkage}} template int B; // expected-error {{templates must have C++ linkage}} template void C(); // expected-error {{templates must have C++ linkage}} // non-template members of a template // FIXME: Should these really be valid? template int A::a; template struct A::b {}; template void A::c() {} template enum class A::d {}; // templates template template int A::e; // expected-error {{templates must have C++ linkage}} template template struct A::f {}; // expected-error {{templates must have C++ linkage}} template template void A::g() {} // expected-error {{templates must have C++ linkage}} // partial specializations template struct A; // expected-error {{templates must have C++ linkage}} template int B; // expected-error {{templates must have C++ linkage}} template template int A::e; // expected-error {{templates must have C++ linkage}} template template struct A::f {}; // expected-error {{templates must have C++ linkage}} // explicit specializations of templates template<> struct A {}; // expected-error {{templates must have C++ linkage}} template<> int B; // expected-error {{templates must have C++ linkage}} template<> void C() {} // expected-error {{templates must have C++ linkage}} // explicit specializations of members of a template template<> int A::a; // expected-error {{templates must have C++ linkage}} template<> struct A::b {}; // expected-error {{templates must have C++ linkage}} template<> void A::c() {} // expected-error {{templates must have C++ linkage}} template<> enum class A::d {}; // expected-error {{templates must have C++ linkage}} // explicit specializations of member templates template<> template int A::e; // expected-error {{templates must have C++ linkage}} template<> template struct A::f {}; // expected-error {{templates must have C++ linkage}} template<> template void A::g() {} // expected-error {{templates must have C++ linkage}} } // Provide valid definitions for the explicit instantiations below. // FIXME: Our recovery from the invalid definitions above isn't very good. template template int A::e; template template struct A::f {}; template template void A::g() {} extern "C" { // explicit instantiations // FIXME: Should these really be valid? template struct A; template int A::a; template struct A::b; template void A::c(); template int A::e; template struct A::f; template void A::g(); } }