3 // RUN: %clang_cc1 -std=c++20 -x c++-header %S/Inputs/header.h -emit-header-unit -o %t/h.pcm
4 // RUN: %clang_cc1 -std=c++20 %s -DX_INTERFACE -emit-module-interface -o %t/x.pcm
5 // RUN: %clang_cc1 -std=c++20 %s -DY_INTERFACE -emit-module-interface -o %t/y.pcm
6 // RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -fmodule-file=X=%t/x.pcm -fmodule-file=Y=%t/y.pcm -emit-module-interface -o %t/m.pcm
7 // RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -I%S/Inputs -fmodule-file=%t/h.pcm \
8 // RUN: -fmodule-file=X=%t/x.pcm -fmodule-file=Y=%t/y.pcm -fmodule-file=p2=%t/m.pcm -verify \
9 // RUN: -Wno-experimental-header-units
10 // RUN: %clang_cc1 -std=c++20 %s -DUSER -I%S/Inputs -fmodule-file=%t/h.pcm -fmodule-file=p2=%t/m.pcm \
11 // RUN: -fmodule-file=X=%t/x.pcm -fmodule-file=Y=%t/y.pcm -Wno-experimental-header-units -verify
13 #if defined(X_INTERFACE)
17 #elif defined(Y_INTERFACE)
21 #elif defined(INTERFACE)
24 import Y
; // not exported
39 namespace D
{ int f(); }
42 #elif defined(IMPLEMENTATION)
46 // Per [basic.scope.namespace]/2.3, exportedness has no impact on visibility
47 // within the same module.
49 // expected-no-diagnostics
55 using namespace A::inner
;
58 using namespace B::inner
;
67 int use_header() { return foo
+ bar::baz(); }
74 // namespace A is implicitly exported by the export of A::g.
75 A::f(); // expected-error {{declaration of 'f' must be imported from module 'p2' before it is required}}
76 // expected-note@* {{declaration here is not visible}}
78 A::h(); // expected-error {{declaration of 'h' must be imported from module 'p2' before it is required}}
79 // expected-note@* {{declaration here is not visible}}
80 using namespace A::inner
; // expected-error {{declaration of 'inner' must be imported from module 'p2' before it is required}}
81 // expected-note@* {{declaration here is not visible}}
83 // namespace B and B::inner are explicitly exported
85 using namespace B::inner
;
86 B::f(); // expected-error {{declaration of 'f' must be imported from module 'p2' before it is required}}
87 // expected-note@* {{declaration here is not visible}}
88 f(); // expected-error {{declaration of 'f' must be imported from module 'p2' before it is required}}
89 // expected-note@* {{declaration here is not visible}}
91 // namespace C is not exported
92 using namespace C
; // expected-error {{declaration of 'C' must be imported from module 'p2' before it is required}}
93 // expected-note@* {{declaration here is not visible}}
95 // namespace D is exported, but D::f is not
96 D::f(); // expected-error {{declaration of 'f' must be imported from module 'p2' before it is required}}
97 // expected-note@* {{declaration here is not visible}}
100 int use_header() { return foo
+ bar::baz(); }