aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2025-06-12 17:42:00 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2025-06-12 17:46:33 +0800
commit1d1f9afe911c360b9505b5fd2c712cb112c8aa5f (patch)
tree1f965d91bb95dbffbafb826349419f21bdc796f7 /clang/lib/Sema/SemaModule.cpp
parent2a27c059eccd96b6e46464dbdf69fd2f6237a56c (diff)
downloadllvm-1d1f9afe911c360b9505b5fd2c712cb112c8aa5f.zip
llvm-1d1f9afe911c360b9505b5fd2c712cb112c8aa5f.tar.gz
llvm-1d1f9afe911c360b9505b5fd2c712cb112c8aa5f.tar.bz2
[C++20] [Modules] Treat directly imported internal partition unit as reachable
Close https://github.com/llvm/llvm-project/issues/143788 See the discussion for details.
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 6c4df0a..9fcaad48 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -712,7 +712,13 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
Mod->Kind == Module::ModuleKind::ModulePartitionImplementation) {
Diag(ExportLoc, diag::err_export_partition_impl)
<< SourceRange(ExportLoc, Path.back().getLoc());
- } else if (!ModuleScopes.empty() && !currentModuleIsImplementation()) {
+ } else if (ExportLoc.isValid() &&
+ (ModuleScopes.empty() || currentModuleIsImplementation())) {
+ // [module.interface]p1:
+ // An export-declaration shall inhabit a namespace scope and appear in the
+ // purview of a module interface unit.
+ Diag(ExportLoc, diag::err_export_not_in_module_interface);
+ } else if (!ModuleScopes.empty()) {
// Re-export the module if the imported module is exported.
// Note that we don't need to add re-exported module to Imports field
// since `Exports` implies the module is imported already.
@@ -720,11 +726,6 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
getCurrentModule()->Exports.emplace_back(Mod, false);
else
getCurrentModule()->Imports.insert(Mod);
- } else if (ExportLoc.isValid()) {
- // [module.interface]p1:
- // An export-declaration shall inhabit a namespace scope and appear in the
- // purview of a module interface unit.
- Diag(ExportLoc, diag::err_export_not_in_module_interface);
}
return Import;