Clang warning: A is a reserved name for a module [-Wreserved-module-identifier] (warn_reserved_module_name)
Jump to navigation
Jump to search
Text | error: A is a reserved name for a module |
---|---|
Type | Warning |
Category | Semantic Issue |
Internal Id | warn_reserved_module_name |
Active by Default | Yes |
Flags | -Wno-reserved-identifier (4 elements) -Wno-reserved-module-identifier (1 element) |
Internal Message | %0 is a reserved name for a module
|
Regular Expression | (?:warning|error|fatal error)\: (.*?) is a reserved name for a module \[(?:\-Werror,)?\-Wreserved\-module\-identifier[^\]]*\]
|
First Commit | 2021-07-10 95f50964fbf5 Implement P2361 Unevaluated string literals |
Description
Example
Flags | -xc++ --std=c++20 -fmodules
|
|
---|---|---|
Source |
// Reserved module name
export module std;
| |
Compiler Output |
<source>:2:15: warning: 'std' is a reserved name for a module [-Wreserved-module-identifier] |
Clang Internals (17.0.6)
Git Commit Message
Implement P2361 Unevaluated string literals This patch proposes to handle in an uniform fashion the parsing of strings that are never evaluated, in asm statement, static assert, attrributes, extern, etc. Unevaluated strings are UTF-8 internally and so currently behave as narrow strings, but these things will diverge with D93031. The big question both for this patch and the P2361 paper is whether we risk breaking code by disallowing encoding prefixes in this context. I hope this patch may allow to gather some data on that. Future work: Improve the rendering of unicode characters, line break and so forth in static-assert messages Reviewed By: aaron.ballman, shafik Differential Revision: https://reviews.llvm.org/D105759
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaModule.cpp (line 166)
/// Tests whether the given identifier is reserved as a module name and
/// diagnoses if it is. Returns true if a diagnostic is emitted and false
/// otherwise.
static bool DiagReservedModuleName(Sema &S, const IdentifierInfo *II, SourceLocation Loc) {
// ...
case Reserved:
S.Diag(Loc, diag::warn_reserved_module_name) << II;
clang/lib/Sema/SemaModule.cpp (line 273)
Sema::DeclGroupPtrTy Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path, ModuleIdPath Partition, ModuleImportState &ImportState) {
// ...
if (!getSourceManager().isInSystemHeader(Path[0].second) && (FirstComponentName == "std" || (FirstComponentName.startswith("std") && llvm::all_of(FirstComponentName.drop_front(3), &llvm::isDigit))))
Diag(Path[0].second, diag::warn_reserved_module_name) << Path[0].first;