Close https://github.com/llvm/llvm-project/issues/60824 The form -fmodule-file=<path-to-BMI> will load modules eagerly and the form -fmodule-file=<module-name>=<path-to-BMI> will load modules lazily. The inconsistency adds many additional burdens to the implementations. And the inconsistency looks not helpful and necessary neither. So I want to deprecate the form -fmodule-file=<path-to-BMI> for named modules. This is pretty helpful for us (the developers). Does this change make any regression from the perspective of the users? To be honest, yes. But I think such regression is acceptable. Here is the example: ``` // M.cppm export module M; export int m = 5; // N.cpp // import M; // woops, we forgot to import M. int n = m; ``` In the original version, the compiler can diagnose the users to import `M` since the compiler have already imported M. But in the later style, the compiler can only say "unknown identifier `m`". But I think such regression doesn't make a deal since it only works if the user put `-fmodule-file=M.pcm` in the command line. But how can the user put `-fmodule-file=M.pcm` in the command line without `import M;`? Especially currently such options are generated by build systems. And the build systems will only generate the command line from the source file. So I think this change is pretty pretty helpful for developers and almost innocent for users and we should accept this one. I'll add the release notes and edit the document after we land this. Differential Revision: https://reviews.llvm.org/D144707
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
// RUN: echo 'export module foo; export int n;' > %t.cppm
|
|
// RUN: %clang_cc1 -std=c++2a %t.cppm -emit-module-interface -o %t.pcm
|
|
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=0 %s
|
|
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=1 %s
|
|
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=2 %s
|
|
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=3 %s
|
|
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=4 %s
|
|
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=5 %s
|
|
|
|
#if MODE == 0
|
|
// no module declaration
|
|
|
|
#elif MODE == 1
|
|
// expected-no-diagnostics
|
|
module foo; // Implementation, implicitly imports foo.
|
|
#define IMPORTED
|
|
|
|
#elif MODE == 2
|
|
export module foo;
|
|
|
|
#elif MODE == 3
|
|
export module bar; // A different module
|
|
|
|
#elif MODE == 4
|
|
module foo:bar; // Partition implementation
|
|
//#define IMPORTED (we don't import foo here)
|
|
|
|
#elif MODE == 5
|
|
export module foo:bar; // Partition interface
|
|
//#define IMPORTED (we don't import foo here)
|
|
|
|
#endif
|
|
|
|
int k = n;
|
|
#ifndef IMPORTED
|
|
// expected-error@-2 {{use of undeclared identifier 'n'}}
|
|
#endif
|