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