57 lines · cpp
1// RUN: %clang_cc1 -std=c++20 %s -verify -pedantic-errors2 3// As amended by P2615R1 applied as a DR against C++20.4export module p3;5 6namespace A { int ns_mem; } // expected-note 2{{target}}7 8// An exported declaration shall declare at least one name.9export; // No diagnostic after P2615R1 DR10export static_assert(true); // No diagnostic after P2615R1 DR11export using namespace A; // No diagnostic after P2615R1 DR12 13export { // No diagnostic after P2615R1 DR14 ; // No diagnostic after P2615R1 DR15 static_assert(true); // No diagnostic after P2615R1 DR16 using namespace A; // No diagnostic after P2615R1 DR17}18 19export struct {}; // expected-error {{must be class member}} expected-error {{GNU extension}} expected-error {{does not declare anything}}20export struct {} struct_;21export union {}; // expected-error {{must be declared 'static'}} expected-error {{does not declare anything}}22export union {} union_;23export enum {}; // expected-error {{does not declare anything}}24export enum {} enum_;25export enum E : int;26export typedef int; // expected-error {{typedef requires a name}}27export static union {}; // expected-error {{does not declare anything}}28export asm(""); // No diagnostic after P2615R1 DR29export namespace B = A;30export using A::ns_mem; // expected-error {{using declaration referring to 'ns_mem' with module linkage cannot be exported}}31namespace A {32 export using A::ns_mem; // expected-error {{using declaration referring to 'ns_mem' with module linkage cannot be exported}}33}34export using Int = int;35export extern "C++" {} // No diagnostic after P2615R1 DR36export extern "C++" { extern "C" {} } // No diagnostic after P2615R1 DR37export extern "C++" { extern "C" int extern_c; }38export { // No diagnostic after P2615R1 DR39 extern "C++" int extern_cxx;40 extern "C++" {} // No diagnostic after P2615R1 DR41}42export [[]]; // No diagnostic after P2615R1 DR43export [[example::attr]]; // expected-warning {{unknown attribute 'example::attr' ignored}}44 45// [...] shall not declare a name with internal linkage46export static int a; // expected-error {{declaration of 'a' with internal linkage cannot be exported}}47export static int b(); // expected-error {{declaration of 'b' with internal linkage cannot be exported}}48export namespace { } // expected-error {{anonymous namespaces cannot be exported}}49export namespace { int c; } // expected-error {{anonymous namespaces cannot be exported}}50namespace { // expected-note {{here}}51 export int d; // expected-error {{export declaration appears within anonymous namespace}}52}53export template<typename> static int e; // expected-error {{declaration of 'e' with internal linkage cannot be exported}}54export template<typename> static int f(); // expected-error {{declaration of 'f' with internal linkage cannot be exported}}55export const int k = 5;56export static union { int n; }; // expected-error {{declaration of 'n' with internal linkage cannot be exported}}57