4 // RUN: split-file %s %t
6 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu1.cpp \
9 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu2.cpp \
10 // RUN: -fmodule-file=B:Y=%t/B_Y.pcm -o %t/B.pcm
12 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu3.cpp \
13 // RUN: -o %t/B_X1.pcm -verify
15 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
16 // RUN: -fmodule-file=B=%t/B.pcm -fmodule-file=B:Y=%t/B_Y.pcm -o %t/B_X2.pcm
18 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex2-tu5.cpp \
19 // RUN: -fmodule-file=B=%t/B.pcm -fmodule-file=B:Y=%t/B_Y.pcm -o %t/b_tu5.o
21 // RUN: %clang_cc1 -std=c++20 -S %t/std10-1-ex2-tu6.cpp \
22 // RUN: -fmodule-file=B=%t/B.pcm -fmodule-file=B:Y=%t/B_Y.pcm -o %t/b_tu6.s -verify
24 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu7.cpp \
25 // RUN: -fmodule-file=B:X2=%t/B_X2.pcm -fmodule-file=B=%t/B.pcm \
26 // RUN: -fmodule-file=B:Y=%t/B_Y.pcm -o %t/B_X3.pcm -verify
28 //--- std10-1-ex2-tu1.cpp
31 // expected-no-diagnostics
33 //--- std10-1-ex2-tu2.cpp
37 // expected-no-diagnostics
39 //--- std10-1-ex2-tu3.cpp
40 module B
:X1
; // does not implicitly import B
41 int &a
= n
; // expected-error {{use of undeclared identifier }}
43 //--- std10-1-ex2-tu4.cpp
44 module B
:X2
; // does not implicitly import B
47 // expected-no-diagnostics
49 //--- std10-1-ex2-tu5.cpp
50 module B
; // implicitly imports B
52 // expected-no-diagnostics
54 //--- std10-1-ex2-tu6.cpp
56 // error, n is module-local and this is not a module.
57 int &c
= n
; // expected-error {{declaration of 'n' must be imported}}
58 // expected-note@* {{declaration here is not visible}}
60 //--- std10-1-ex2-tu7.cpp
61 // expected-no-diagnostics
62 module B
:X3
; // does not implicitly import B
63 import
:X2
; // X2 is an implementation unit import B.
64 // According to [module.import]p7:
65 // Additionally, when a module-import-declaration in a module unit of some
66 // module M imports another module unit U of M, it also imports all
67 // translation units imported by non-exported module-import-declarations in
68 // the module unit purview of U.
70 // So B is imported in B:X3 due to B:X2 imported B. So n is visible here.