The following test fails to compile TU b.cpp because we are not making the transitively imported modules visible (per [module.import]/p7)
```
a.cppm:
export module a;
export int foo() {
return 42;
}
b.cppm:
export module b;
import a;
export int bar();
b.cpp:
module b;
int bar() {
return foo();
}
clang++ -c -std=c++2b -fmodule-output a.cppm
clang++ -c -std=c++2b -fmodule-output -fprebuilt-module-path=. b.cppm
clang++ -c -std=c++2b -fprebuilt-module-path=. b.cpp
b.cpp:4:12: error: declaration of 'foo' must be imported from module 'a' before it is required
return foo();
```
This is fixed by the following patch (which also addresses a FIXME in basic.def.odr/p6.cppm).
Differential Revision: https://reviews.llvm.org/D152746
50 lines
880 B
C++
50 lines
880 B
C++
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
|
|
// All of the following should build without diagnostics.
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/a.cpp -emit-module-interface -o %t/a.pcm
|
|
// R U N: %clang_cc1 -std=c++20 %t/a.pcm -emit-obj -o %t/a.o
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/b.cpp -emit-module-interface -o %t/b.pcm \
|
|
// RUN: -fprebuilt-module-path=%t
|
|
// R U N: %clang_cc1 -std=c++20 %t/b.pcm -emit-obj -o %t/b.o
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/b-impl.cpp -emit-obj -o %t/b-impl.o \
|
|
// RUN: -fprebuilt-module-path=%t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/ab-main.cpp -fsyntax-only \
|
|
// RUN: -fprebuilt-module-path=%t
|
|
|
|
//--- a.cpp
|
|
|
|
export module a;
|
|
|
|
export int foo() {
|
|
return 42;
|
|
}
|
|
|
|
//--- b.cpp
|
|
|
|
export module b;
|
|
import a;
|
|
|
|
export int bar();
|
|
|
|
//--- b-impl.cpp
|
|
|
|
module b;
|
|
|
|
int bar() {
|
|
return foo();
|
|
}
|
|
|
|
//--- ab-main.cpp
|
|
|
|
import b;
|
|
|
|
int main() {
|
|
return bar();
|
|
}
|
|
|