1 // Based on C++20 10.2 example 2. 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-header-unit -I %t \ 8 // RUN: -xc++-user-header std-10-2-ex2-c.h -o %t/std-10-2-ex2-c.pcm 9 10 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std-10-2-ex2-tu1.cpp \ 11 // RUN: -o %t/X.pcm 12 13 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std-10-2-ex2-tu2.cpp \ 14 // RUN: -fmodule-file=%t/std-10-2-ex2-c.pcm -fmodule-file=X=%t/X.pcm \ 15 // RUN: -pedantic-errors -verify -o %t/M.pcm 16 17 // Test again with reduced BMI. 18 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -I %t \ 19 // RUN: -xc++-user-header std-10-2-ex2-c.h -o %t/std-10-2-ex2-c.pcm 20 21 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std-10-2-ex2-tu1.cpp \ 22 // RUN: -o %t/X.pcm 23 24 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std-10-2-ex2-tu2.cpp \ 25 // RUN: -fmodule-file=%t/std-10-2-ex2-c.pcm -fmodule-file=X=%t/X.pcm \ 26 // RUN: -pedantic-errors -verify -o %t/M.pcm 27 28 29 //--- std-10-2-ex2-b.h 30 int f(); 31 32 //--- std-10-2-ex2-c.h 33 int g(); 34 35 //--- std-10-2-ex2-tu1.cpp 36 export module X; 37 export int h(); 38 39 //--- std-10-2-ex2-tu2.cpp 40 module; 41 #include "std-10-2-ex2-b.h" 42 43 export module M; 44 import "std-10-2-ex2-c.h"; // expected-warning {{the implementation of header units is in an experimental phase}} 45 import X; 46 export using ::f, ::g, ::h; // OK 47 struct S; // expected-note {{target of using declaration}} 48 export using ::S; // expected-error {{using declaration referring to 'S' with module linkage cannot be exported}} 49 50 namespace N { 51 export int h(); 52 static int h(int); // expected-note {{target of using declaration}} 53 } // namespace N 54 export using N::h; // expected-error {{using declaration referring to 'h' with internal linkage cannot be exported}} 55