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