[clang] [Clang][CTAD] Implement deduction guides for alias templates with nested aliases (PR #222215)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 15 01:33:26 PDT 2026
================
@@ -1177,13 +1177,40 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) {
auto RhsType = AliasTemplate->getTemplatedDecl()->getUnderlyingType();
TemplateDecl *Template = nullptr;
llvm::ArrayRef<TemplateArgument> AliasRhsTemplateArgs;
- if (const auto *TST = RhsType->getAs<TemplateSpecializationType>()) {
+ const auto *TST = RhsType->getAs<TemplateSpecializationType>();
+
+ // The RHS of the alias may name another alias template that can never have
+ // deduction guides of its own, because its defining-type-id is not of the
+ // form
+ // [typename] [nested-name-specifier] [template] simple-template-id
+ // as required by [over.match.class.deduct]p3. e.g.
+ // template <typename T>
+ // using Identity = T;
+ // template <typename T>
+ // using C = Identity<Foo<T>>;
+ // Per [temp.alias]p2, Identity<Foo<T>> is equivalent to Foo<T>, so step
+ // through such aliases and derive the deduction guides from the first
+ // template that can actually have them (GH125821).
----------------
cor3ntin wrote:
> direction that currently has agreement in principle
Can you confirm you mean:
> Names resolve to underlying entities per 6.1 [[basic.pre](https://wg21.link/basic.pre#8)] paragraph 8. Define the underlying entity of a simple alias template to be (the underlying entity of) the defining-type-id instead of introducing "equivalent". In order to qualify as a simple alias template, neither the alias template nor the referred-to template can have default template arguments in their template-heads.
https://github.com/llvm/llvm-project/pull/222215
More information about the cfe-commits
mailing list