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

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 20 02:55: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;
+      }
+    }
+
----------------
zyn0217 wrote:

@cor3ntin @erichkeane 

I don't understand why we were skipping past template parameter scopes even prior to @sdkrystian's patch. It doesn't seem very right for this case.

https://github.com/llvm/llvm-project/commit/c1d8d0aa156f651ee48414fa002e9608d6998763#diff-9ced4fa47ee2b9c03b6996ce89a1d131c0f5b71013993bc582209f50d5e934daL13519

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


More information about the cfe-commits mailing list