llvm-project/clang/test/Modules/no-implicit-std-cxx-module.cppm
Chuanqi Xu dc4e85bd79 [C++20] [Modules] Remove hardcoded path to imported module in BMIs
Close https://github.com/llvm/llvm-project/issues/62707

As we discussed before, we'll forbid the use of implicit generated path
for C++20 modules. And as I mentioned in
https://github.com/llvm/llvm-project/issues/62707, we've emitted a
warning for clang17 and we'll make it a hard error in clang18. And the
patch addresses the decision.
2024-01-12 13:47:59 +08:00

28 lines
659 B
C++

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: cd %t
//
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -o %t/b.pcm
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -fmodule-file=b=%t/b.pcm \
// RUN: -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/user.cpp -fmodule-file=a=%t/a.pcm -verify -fsyntax-only
//--- b.cppm
export module b;
export int b() {
return 43;
}
//--- a.cppm
export module a;
import b;
export int a() {
return b() + 43;
}
//--- user.cpp
import a; // expected-error {{failed to find module file for module 'b'}}
int use() {
return a(); // expected-error {{use of undeclared identifier 'a'}}
}