aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2023-03-28 08:52:37 -0400
committerAaron Ballman <aaron@aaronballman.com>2023-03-28 08:53:44 -0400
commite574833c2bc46a39150156eb973d0efb142bc618 (patch)
tree5ecd6be91f2b343a57acf18f633d3fc087143683 /clang/lib/Sema/SemaModule.cpp
parent5aef3dfad685f3129ffd4c4066963c8026693673 (diff)
downloadllvm-e574833c2bc46a39150156eb973d0efb142bc618.zip
llvm-e574833c2bc46a39150156eb973d0efb142bc618.tar.gz
llvm-e574833c2bc46a39150156eb973d0efb142bc618.tar.bz2
Downgrade reserved module identifier error into a warning
Any project that wants to import std; potentially needs to be able to build a module that does export std;. We silenced the error diagnostic if the module identified itself as a system header, but this isn't quite good enough, what we really need is a way to identify a system module. It would be nice for that feature to be shared among the major implementations, so this downgrades the diagnostic from an error to a warning temporarily to give implementers time to determine what that mechanism will look like. We may convert this warning back into an error in a future release of Clang, but it's not guaranteed we will do so. Fixes https://github.com/llvm/llvm-project/issues/61446 Differential Revision: https://reviews.llvm.org/D146986
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 8c120d2..40ebc9c 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -156,11 +156,15 @@ static bool DiagReservedModuleName(Sema &S, const IdentifierInfo *II,
if (Reason == Reserved && S.getSourceManager().isInSystemHeader(Loc))
Reason = Valid;
- if (Reason != Valid) {
- S.Diag(Loc, diag::err_invalid_module_name) << II << (int)Reason;
- return true;
+ switch (Reason) {
+ case Valid:
+ return false;
+ case Invalid:
+ return S.Diag(Loc, diag::err_invalid_module_name) << II;
+ case Reserved:
+ return S.Diag(Loc, diag::warn_reserved_module_name) << II;
}
- return false;
+ llvm_unreachable("fell off a fully covered switch");
}
Sema::DeclGroupPtrTy
@@ -264,8 +268,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
(FirstComponentName == "std" ||
(FirstComponentName.startswith("std") &&
llvm::all_of(FirstComponentName.drop_front(3), &llvm::isDigit)))) {
- Diag(Path[0].second, diag::err_invalid_module_name)
- << Path[0].first << /*reserved*/ 1;
+ Diag(Path[0].second, diag::warn_reserved_module_name) << Path[0].first;
return nullptr;
}