Clang error: declaration of A shadows template parameter (err_template_param_shadow)
Jump to navigation
Jump to search
Text | error: declaration of A shadows template parameter |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_template_param_shadow |
Internal Message | declaration of %0 shadows template parameter
|
Regular Expression | (?:error|fatal error)\: declaration of (.*?) shadows template parameter
|
First Commit | 2009-03-14 5a8987ca5113 Update tablegen diagnostic files to be in sync with the def files. |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
template<typename T>
void f() {
int T = 0; // T shadows
}
| |
Compiler Output |
<source>:3:7: error: declaration of 'T' shadows template parameter <source>:1:19: note: template parameter is declared here |
Clang Internals (17.0.6)
Git Commit Message
Update tablegen diagnostic files to be in sync with the def files. llvm-svn: 67004
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/SemaLambda.cpp (line 1380)
void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Declarator &ParamInfo, const DeclSpec &DS) {
// ...
if (TemplateParams) {
for (const auto *TP : TemplateParams->asArray()) {
// ...
for (const auto &Capture : Intro.Captures) {
if (Capture.Id == TP->getIdentifier()) {
Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
clang/lib/Sema/SemaTemplate.cpp (line 897)
/// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
/// that the template parameter 'PrevDecl' is being shadowed by a new
/// declaration at location Loc. Returns true to indicate that this is
/// an error, and false otherwise.
void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) {
// ...
unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow : diag::err_template_param_shadow;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
- clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp:80:11: error: declaration of 'T' shadows template parameter
- clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp:98:11: error: declaration of 'T' shadows template parameter