From c1f76363e0db41ab6eb9ebedd687ee098491e9b7 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 13 Apr 2023 15:08:21 +0800 Subject: [C++20] [Modules] Continue parsing after we found reserved module names Close https://github.com/llvm/llvm-project/issues/62112 In the previous change, we'll stop parsing directly after we found reserved module names. But this may be too aggressive. This patch changes this. Note that the parsing will still be stopped if the module name is `module` or `import`. --- clang/lib/Sema/SemaModule.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'clang/lib/Sema/SemaModule.cpp') diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index 6c39cc0..84a1fd8 100644 --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -162,7 +162,8 @@ static bool DiagReservedModuleName(Sema &S, const IdentifierInfo *II, case Invalid: return S.Diag(Loc, diag::err_invalid_module_name) << II; case Reserved: - return S.Diag(Loc, diag::warn_reserved_module_name) << II; + S.Diag(Loc, diag::warn_reserved_module_name) << II; + return false; } llvm_unreachable("fell off a fully covered switch"); } @@ -267,10 +268,8 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, if (!getSourceManager().isInSystemHeader(Path[0].second) && (FirstComponentName == "std" || (FirstComponentName.startswith("std") && - llvm::all_of(FirstComponentName.drop_front(3), &llvm::isDigit)))) { + llvm::all_of(FirstComponentName.drop_front(3), &llvm::isDigit)))) Diag(Path[0].second, diag::warn_reserved_module_name) << Path[0].first; - return nullptr; - } // Then test all of the components in the path to see if any of them are // using another kind of reserved or invalid identifier. -- cgit v1.1