95 lines · cpp
1 2// RUN: rm -rf %t3// RUN: mkdir -p %t4// RUN: split-file %s %t5 6// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu1.cpp \7// RUN: -o %t/B_Y.pcm8//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.pcm11//12// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu3.cpp \13// RUN: -o %t/B_X1.pcm -verify14//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.pcm17//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.o20//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 -verify23//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 -verify27 28// Test again with reduced BMI.29// RUN: rm %t/B_X2.pcm %t/B.pcm %t/B_Y.pcm30// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex2-tu1.cpp \31// RUN: -o %t/B_Y.pcm32//33// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex2-tu2.cpp \34// RUN: -fmodule-file=B:Y=%t/B_Y.pcm -o %t/B.pcm35//36// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex2-tu3.cpp \37// RUN: -o %t/B_X1.pcm -verify38//39// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex2-tu4.cpp \40// RUN: -fmodule-file=B=%t/B.pcm -fmodule-file=B:Y=%t/B_Y.pcm -o %t/B_X2.pcm41//42// RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex2-tu5.cpp \43// RUN: -fmodule-file=B=%t/B.pcm -fmodule-file=B:Y=%t/B_Y.pcm -o %t/b_tu5.o44//45// RUN: %clang_cc1 -std=c++20 -S %t/std10-1-ex2-tu6.cpp \46// RUN: -fmodule-file=B=%t/B.pcm -fmodule-file=B:Y=%t/B_Y.pcm -o %t/b_tu6.s -verify47//48// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex2-tu7.cpp \49// RUN: -fmodule-file=B:X2=%t/B_X2.pcm -fmodule-file=B=%t/B.pcm \50// RUN: -fmodule-file=B:Y=%t/B_Y.pcm -o %t/B_X3.pcm -verify51 52//--- std10-1-ex2-tu1.cpp53module B:Y;54int y();55// expected-no-diagnostics56 57//--- std10-1-ex2-tu2.cpp58export module B;59import :Y;60int n = y();61// expected-no-diagnostics62 63//--- std10-1-ex2-tu3.cpp64module B:X1; // does not implicitly import B65int &a = n; // expected-error {{use of undeclared identifier }}66 67//--- std10-1-ex2-tu4.cpp68module B:X2; // does not implicitly import B69import B;70int &b = n; // OK71// expected-no-diagnostics72 73//--- std10-1-ex2-tu5.cpp74module B; // implicitly imports B75int &c = n; // OK76// expected-no-diagnostics77 78//--- std10-1-ex2-tu6.cpp79import B;80// error, n is module-local and this is not a module.81int &c = n; // expected-error {{use of undeclared identifier 'n'}}82 83//--- std10-1-ex2-tu7.cpp84// expected-no-diagnostics85module B:X3; // does not implicitly import B86import :X2; // X2 is an implementation unit import B.87// According to [module.import]p7:88// Additionally, when a module-import-declaration in a module unit of some89// module M imports another module unit U of M, it also imports all90// translation units imported by non-exported module-import-declarations in91// the module unit purview of U.92//93// So B is imported in B:X3 due to B:X2 imported B. So n is visible here.94int &c = n;95