1 // Based on C++20 10.2 example 1. 2 3 // RUN: rm -rf %t 4 // RUN: mkdir -p %t 5 // RUN: split-file %s %t 6 7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std-10-2-ex1-tu1.cpp \ 8 // RUN: -pedantic-errors -verify -o %t/m1.pcm 9 10 //--- std-10-2-ex1.h 11 export int x; 12 13 //--- std-10-2-ex1-tu1.cpp 14 module; 15 16 #include "std-10-2-ex1.h" 17 // expected-error@std-10-2-ex1.h:* {{export declaration can only be used within a module purview}} 18 19 export module M1; 20 export namespace {} // expected-error {{anonymous namespaces cannot be exported}} 21 export namespace { // expected-error {{anonymous namespaces cannot be exported}} 22 int a1; 23 } 24 namespace { // expected-note {{anonymous namespace begins here}} 25 export int a2; // expected-error {{export declaration appears within anonymous namespace}} 26 } 27 export static int b; // expected-error {{declaration of 'b' with internal linkage cannot be exported}} 28 export int f(); // OK 29 30 export namespace N {} // namespace N 31 export using namespace N; // No diagnostic after P2615R1 DR 32