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