================
@@ -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;
+      }
+    }
+
----------------
zygoloid wrote:

I would think that we still need to do this `S = S->getDeclParent();` step, 
like we do in `HandleDeclarator` and elsewhere, but we're just doing it at the 
wrong moment -- it should be done after we do lookup and before we pass `S` to 
`FilterLookupForScope` and `PushOnScopeChains`.

I think removing it entirely happens to work because alias templates can only 
appear in scopes that correspond to a `DeclContext`, so the change to push the 
name into the "wrong" `Scope` turns out to not matter -- lookup in the 
`DeclContext` finds it anyway. So I'm not sure if the difference is observable, 
but it would be more correct to move the `S = S->getDeclParent();` step to 
after the lookup instead of removing it entirely. (This is what 
`HandleDeclarator` does, so it's what we do for `typedef`.)

https://github.com/llvm/llvm-project/pull/123533
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to