[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 22 06:15:42 PST 2025


================
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, AccessSpecifier AS,
     }
     TemplateParameterList *TemplateParams = TemplateParamLists[0];
 
+    // Check shadowing of a template parameter name
+    for (NamedDecl *TP : TemplateParams->asArray()) {
+      if (NameInfo.getName() == TP->getDeclName()) {
+        DiagnoseTemplateParameterShadow(Name.StartLocation, TP);
+        return nullptr;
+      }
+    }
+
----------------
erichkeane wrote:

That doesn't seem right... I would expect it to?  But someone probably needs to change it and see what happens, or dig through git history to see if there is justification for this.

https://github.com/llvm/llvm-project/pull/123533


More information about the cfe-commits mailing list