[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-13 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov closed 
https://github.com/llvm/llvm-project/pull/91833
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-13 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM, thanks!

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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-13 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/91833

>From 06b9c19a1d194240be3199d50819090b10d697b6 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 10 May 2024 23:21:22 -0300
Subject: [PATCH] [clang] Allow pack expansions when partial ordering against
 template template parameters

When partial ordering alias templates against template template parameters,
allow pack expansions when the alias has a fixed-size parameter list.

These expansions were generally disallowed by proposed resolution for CWG1430.

By previously diagnosing these when checking template template parameters, we
would be too strict in trying to prevent any potential invalid use.

This flows against the more general idea that template template parameters are
weakly typed, that we would rather allow an argument that might be possibly
misused, and only diagnose the actual misuses during instantiation.

Since this interaction between P0522R0 and CWG1430 is also a backwards-compat
breaking change, we implement provisional wording to allow these.

Fixes https://github.com/llvm/llvm-project/issues/62529
---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/include/clang/Sema/Sema.h|  8 +++-
 clang/lib/Sema/SemaTemplate.cpp| 14 ++
 clang/lib/Sema/SemaTemplateDeduction.cpp   |  4 +++-
 ...plate_cxx1z.cpp => temp_arg_template_p0522.cpp} | 12 ++--
 5 files changed, 32 insertions(+), 8 deletions(-)
 rename clang/test/SemaTemplate/{temp_arg_template_cxx1z.cpp => 
temp_arg_template_p0522.cpp} (91%)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4702b8c10cdbb..28ac54127383a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -708,6 +708,8 @@ Bug Fixes to C++ Support
   expression.
 - Fix a bug in access control checking due to dealyed checking of friend 
declaration. Fixes (#GH12361).
 - Correctly treat the compound statement of an ``if consteval`` as an 
immediate context. Fixes (#GH91509).
+- When partial ordering alias templates against template template parameters,
+  allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4efd3878e861b..869769f95fd7f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9216,6 +9216,12 @@ class Sema final : public SemaBase {
   /// receive true if the cause for the error is the associated constraints of
   /// the template not being satisfied by the template arguments.
   ///
+  /// \param PartialOrderingTTP If true, assume these template arguments are
+  /// the injected template arguments for a template template parameter.
+  /// This will relax the requirement that all its possible uses are valid:
+  /// TTP checking is loose, and assumes that invalid uses will be diagnosed
+  /// during instantiation.
+  ///
   /// \returns true if an error occurred, false otherwise.
   bool CheckTemplateArgumentList(
   TemplateDecl *Template, SourceLocation TemplateLoc,
@@ -9223,7 +9229,7 @@ class Sema final : public SemaBase {
   SmallVectorImpl ,
   SmallVectorImpl ,
   bool UpdateArgsWithConversions = true,
-  bool *ConstraintsNotSatisfied = nullptr);
+  bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = 
false);
 
   bool CheckTemplateTypeArgument(
   TemplateTypeParmDecl *Param, TemplateArgumentLoc ,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index bae00c6292703..8219d5eed8db7 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6556,7 +6556,8 @@ bool Sema::CheckTemplateArgumentList(
 TemplateArgumentListInfo , bool PartialTemplateArgs,
 SmallVectorImpl ,
 SmallVectorImpl ,
-bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied) {
+bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied,
+bool PartialOrderingTTP) {
 
   if (ConstraintsNotSatisfied)
 *ConstraintsNotSatisfied = false;
@@ -6627,9 +6628,14 @@ bool Sema::CheckTemplateArgumentList(
   bool PackExpansionIntoNonPack =
   NewArgs[ArgIdx].getArgument().isPackExpansion() &&
   (!(*Param)->isTemplateParameterPack() || 
getExpandedPackSize(*Param));
-  if (PackExpansionIntoNonPack && (isa(Template) ||
-   isa(Template))) {
-// Core issue 1430: we have a pack expansion as an argument to an
+  // CWG1430: Don't diagnose this pack expansion when partial
+  // ordering template template parameters. Some uses of the template could
+  // be valid, and invalid uses will be diagnosed later during
+  // instantiation.
+  if (PackExpansionIntoNonPack && !PartialOrderingTTP &&
+  (isa(Template) ||
+   isa(Template))) {
+// 

[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-13 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/91833

>From f882dca5a53a6da8ad92492f28f9eacffb34a780 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 10 May 2024 23:21:22 -0300
Subject: [PATCH] [clang] Allow pack expansions when partial ordering against
 template template parameters

When partial ordering alias templates against template template parameters,
allow pack expansions when the alias has a fixed-size parameter list.

These expansions were generally disallowed by proposed resolution for CWG1430.

By previously diagnosing these when checking template template parameters, we
would be too strict in trying to prevent any potential invalid use.

This flows against the more general idea that template template parameters are
weakly typed, that we would rather allow an argument that might be possibly
misused, and only diagnose the actual misuses during instantiation.

Since this interaction between P0522R0 and CWG1430 is also a backwards-compat
breaking change, we implement provisional wording to allow these.

Fixes https://github.com/llvm/llvm-project/issues/62529
---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/include/clang/Sema/Sema.h|  8 +++-
 clang/lib/Sema/SemaTemplate.cpp| 14 ++
 clang/lib/Sema/SemaTemplateDeduction.cpp   |  4 +++-
 ...plate_cxx1z.cpp => temp_arg_template_p0522.cpp} | 12 ++--
 5 files changed, 32 insertions(+), 8 deletions(-)
 rename clang/test/SemaTemplate/{temp_arg_template_cxx1z.cpp => 
temp_arg_template_p0522.cpp} (91%)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7c5dcc59c7016..b9380357d04e6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -707,6 +707,8 @@ Bug Fixes to C++ Support
   initialized, rather than evaluating them as a part of the larger manifestly 
constant evaluated
   expression.
 - Fix a bug in access control checking due to dealyed checking of friend 
declaration. Fixes (#GH12361).
+- When partial ordering alias templates against template template parameters,
+  allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4efd3878e861b..869769f95fd7f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9216,6 +9216,12 @@ class Sema final : public SemaBase {
   /// receive true if the cause for the error is the associated constraints of
   /// the template not being satisfied by the template arguments.
   ///
+  /// \param PartialOrderingTTP If true, assume these template arguments are
+  /// the injected template arguments for a template template parameter.
+  /// This will relax the requirement that all its possible uses are valid:
+  /// TTP checking is loose, and assumes that invalid uses will be diagnosed
+  /// during instantiation.
+  ///
   /// \returns true if an error occurred, false otherwise.
   bool CheckTemplateArgumentList(
   TemplateDecl *Template, SourceLocation TemplateLoc,
@@ -9223,7 +9229,7 @@ class Sema final : public SemaBase {
   SmallVectorImpl ,
   SmallVectorImpl ,
   bool UpdateArgsWithConversions = true,
-  bool *ConstraintsNotSatisfied = nullptr);
+  bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = 
false);
 
   bool CheckTemplateTypeArgument(
   TemplateTypeParmDecl *Param, TemplateArgumentLoc ,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 480c0103ae335..954363259f6f2 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6436,7 +6436,8 @@ bool Sema::CheckTemplateArgumentList(
 TemplateArgumentListInfo , bool PartialTemplateArgs,
 SmallVectorImpl ,
 SmallVectorImpl ,
-bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied) {
+bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied,
+bool PartialOrderingTTP) {
 
   if (ConstraintsNotSatisfied)
 *ConstraintsNotSatisfied = false;
@@ -6507,9 +6508,14 @@ bool Sema::CheckTemplateArgumentList(
   bool PackExpansionIntoNonPack =
   NewArgs[ArgIdx].getArgument().isPackExpansion() &&
   (!(*Param)->isTemplateParameterPack() || 
getExpandedPackSize(*Param));
-  if (PackExpansionIntoNonPack && (isa(Template) ||
-   isa(Template))) {
-// Core issue 1430: we have a pack expansion as an argument to an
+  // CWG1430: Don't diagnose this pack expansion when partial
+  // ordering template template parameters. Some uses of the template could
+  // be valid, and invalid uses will be diagnosed later during
+  // instantiation.
+  if (PackExpansionIntoNonPack && !PartialOrderingTTP &&
+  (isa(Template) ||
+   isa(Template))) {
+// CWG1430: 

[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-13 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/91833
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-13 Thread via cfe-commits

cor3ntin wrote:

I have confirmed that with this change, `stdexec` compiles successfully, 
addressing both #89807 and #91787

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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-11 Thread via cfe-commits


@@ -9216,14 +9216,20 @@ class Sema final : public SemaBase {
   /// receive true if the cause for the error is the associated constraints of
   /// the template not being satisfied by the template arguments.
   ///
+  /// \param PartialOrderTTP If true, assume these template arguments are
+  /// the injected template arguments for a template template parameter.
+  /// This will relax the requirement that all it's possible uses are valid.

cor3ntin wrote:

```suggestion
  /// This will relax the requirement that all its possible uses are valid:
```

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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-11 Thread via cfe-commits


@@ -707,6 +707,7 @@ Bug Fixes to C++ Support
   initialized, rather than evaluating them as a part of the larger manifestly 
constant evaluated
   expression.
 - Fix a bug in access control checking due to dealyed checking of friend 
declaration. Fixes (#GH12361).
+- When partial ordering alias templates against template template parameters, 
allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).

cor3ntin wrote:

```suggestion
- When partial ordering alias templates against template template parameters, 
   allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).
```

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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-11 Thread via cfe-commits


@@ -6436,7 +6436,8 @@ bool Sema::CheckTemplateArgumentList(
 TemplateArgumentListInfo , bool PartialTemplateArgs,
 SmallVectorImpl ,
 SmallVectorImpl ,
-bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied) {
+bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied,
+bool PartialOrderTTP) {

cor3ntin wrote:

```suggestion
bool PartialOrderingTTP) {
```

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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-11 Thread via cfe-commits

https://github.com/cor3ntin commented:

Looks sensible to me but let's wait a bit (I'll try to run tests on stdexec 
with that change)

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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-11 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/91833
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-11 Thread Erich Keane via cfe-commits


@@ -6507,8 +6508,13 @@ bool Sema::CheckTemplateArgumentList(
   bool PackExpansionIntoNonPack =
   NewArgs[ArgIdx].getArgument().isPackExpansion() &&
   (!(*Param)->isTemplateParameterPack() || 
getExpandedPackSize(*Param));
-  if (PackExpansionIntoNonPack && (isa(Template) ||
-   isa(Template))) {
+  // Core issue 1430: Don't diagnose this pack expansion when partial

erichkeane wrote:

```suggestion
  // Core issue CWG1430: Don't diagnose this pack expansion when partial
```

(makes it easier to grep for)

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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-11 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


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


[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

When partial ordering alias templates against template template parameters, 
allow pack expansions when the alias has a fixed-size parameter list.

These expansions were generally disallowed by proposed resolution for CWG1430.

By previously diagnosing these when checking template template parameters, we 
would be too strict in trying to prevent any potential invalid use.

This flows against the more general idea that template template parameters are 
weakly typed, that we would rather allow an argument that might be possibly 
misused, and only diagnose the actual misuses during instantiation.

Since this interaction between P0522R0 and CWG1430 is also a backwards-compat 
breaking change, we implement provisional wording to allow these.

Fixes https://github.com/llvm/llvm-project/issues/62529

---
Full diff: https://github.com/llvm/llvm-project/pull/91833.diff


5 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/include/clang/Sema/Sema.h (+7-1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+9-3) 
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+3-1) 
- (renamed) clang/test/SemaTemplate/temp_arg_template_p0522.cpp (+10-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7c5dcc59c7016..ddc5d5ff16a34 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -707,6 +707,7 @@ Bug Fixes to C++ Support
   initialized, rather than evaluating them as a part of the larger manifestly 
constant evaluated
   expression.
 - Fix a bug in access control checking due to dealyed checking of friend 
declaration. Fixes (#GH12361).
+- When partial ordering alias templates against template template parameters, 
allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4efd3878e861b..3fc59488243e5 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9216,6 +9216,12 @@ class Sema final : public SemaBase {
   /// receive true if the cause for the error is the associated constraints of
   /// the template not being satisfied by the template arguments.
   ///
+  /// \param PartialOrderTTP If true, assume these template arguments are
+  /// the injected template arguments for a template template parameter.
+  /// This will relax the requirement that all it's possible uses are valid.
+  /// TTP checking is loose, and assumes that invalid uses will be diagnosed
+  /// during instantiation.
+  ///
   /// \returns true if an error occurred, false otherwise.
   bool CheckTemplateArgumentList(
   TemplateDecl *Template, SourceLocation TemplateLoc,
@@ -9223,7 +9229,7 @@ class Sema final : public SemaBase {
   SmallVectorImpl ,
   SmallVectorImpl ,
   bool UpdateArgsWithConversions = true,
-  bool *ConstraintsNotSatisfied = nullptr);
+  bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderTTP = false);
 
   bool CheckTemplateTypeArgument(
   TemplateTypeParmDecl *Param, TemplateArgumentLoc ,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 480c0103ae335..88d0af191e6c8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6436,7 +6436,8 @@ bool Sema::CheckTemplateArgumentList(
 TemplateArgumentListInfo , bool PartialTemplateArgs,
 SmallVectorImpl ,
 SmallVectorImpl ,
-bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied) {
+bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied,
+bool PartialOrderTTP) {
 
   if (ConstraintsNotSatisfied)
 *ConstraintsNotSatisfied = false;
@@ -6507,8 +6508,13 @@ bool Sema::CheckTemplateArgumentList(
   bool PackExpansionIntoNonPack =
   NewArgs[ArgIdx].getArgument().isPackExpansion() &&
   (!(*Param)->isTemplateParameterPack() || 
getExpandedPackSize(*Param));
-  if (PackExpansionIntoNonPack && (isa(Template) ||
-   isa(Template))) {
+  // Core issue 1430: Don't diagnose this pack expansion when partial
+  // ordering template template parameters. Some uses of the template could
+  // be valid, and invalid uses will be diagnosed later during
+  // instantiation.
+  if (PackExpansionIntoNonPack && !PartialOrderTTP &&
+  (isa(Template) ||
+   isa(Template))) {
 // Core issue 1430: we have a pack expansion as an argument to an
 // alias template, and it's not part of a parameter pack. This
 // can't be canonicalized, so reject it now.
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index fe7e35d841510..853c0e1b50619 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ 

[clang] [clang] Allow pack expansions when partial ordering against template template parameters (PR #91833)

2024-05-10 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/91833

When partial ordering alias templates against template template parameters, 
allow pack expansions when the alias has a fixed-size parameter list.

These expansions were generally disallowed by proposed resolution for CWG1430.

By previously diagnosing these when checking template template parameters, we 
would be too strict in trying to prevent any potential invalid use.

This flows against the more general idea that template template parameters are 
weakly typed, that we would rather allow an argument that might be possibly 
misused, and only diagnose the actual misuses during instantiation.

Since this interaction between P0522R0 and CWG1430 is also a backwards-compat 
breaking change, we implement provisional wording to allow these.

Fixes https://github.com/llvm/llvm-project/issues/62529

>From 98fdfb900582cb5f69c56b5c00106dbeff238338 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 10 May 2024 23:21:22 -0300
Subject: [PATCH] [clang] Allow pack expansions when partial ordering against
 template template parameters

When partial ordering alias templates against template template parameters,
allow pack expansions when the alias has a fixed-size parameter list.

These expansions were generally disallowed by proposed resolution for CWG1430.

By previously diagnosing these when checking template template parameters, we
would be too strict in trying to prevent any potential invalid use.

This flows against the more general idea that template template parameters are
weakly typed, that we would rather allow an argument that might be possibly
misused, and only diagnose the actual misuses during instantiation.

Since this interaction between P0522R0 and CWG1430 is also a backwards-compat
breaking change, we implement provisional wording to allow these.

Fixes https://github.com/llvm/llvm-project/issues/62529
---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/include/clang/Sema/Sema.h  |  8 +++-
 clang/lib/Sema/SemaTemplate.cpp  | 12 +---
 clang/lib/Sema/SemaTemplateDeduction.cpp |  4 +++-
 ...emplate_cxx1z.cpp => temp_arg_template_p0522.cpp} | 12 ++--
 5 files changed, 30 insertions(+), 7 deletions(-)
 rename clang/test/SemaTemplate/{temp_arg_template_cxx1z.cpp => 
temp_arg_template_p0522.cpp} (91%)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7c5dcc59c7016..ddc5d5ff16a34 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -707,6 +707,7 @@ Bug Fixes to C++ Support
   initialized, rather than evaluating them as a part of the larger manifestly 
constant evaluated
   expression.
 - Fix a bug in access control checking due to dealyed checking of friend 
declaration. Fixes (#GH12361).
+- When partial ordering alias templates against template template parameters, 
allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4efd3878e861b..3fc59488243e5 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9216,6 +9216,12 @@ class Sema final : public SemaBase {
   /// receive true if the cause for the error is the associated constraints of
   /// the template not being satisfied by the template arguments.
   ///
+  /// \param PartialOrderTTP If true, assume these template arguments are
+  /// the injected template arguments for a template template parameter.
+  /// This will relax the requirement that all it's possible uses are valid.
+  /// TTP checking is loose, and assumes that invalid uses will be diagnosed
+  /// during instantiation.
+  ///
   /// \returns true if an error occurred, false otherwise.
   bool CheckTemplateArgumentList(
   TemplateDecl *Template, SourceLocation TemplateLoc,
@@ -9223,7 +9229,7 @@ class Sema final : public SemaBase {
   SmallVectorImpl ,
   SmallVectorImpl ,
   bool UpdateArgsWithConversions = true,
-  bool *ConstraintsNotSatisfied = nullptr);
+  bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderTTP = false);
 
   bool CheckTemplateTypeArgument(
   TemplateTypeParmDecl *Param, TemplateArgumentLoc ,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 480c0103ae335..88d0af191e6c8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6436,7 +6436,8 @@ bool Sema::CheckTemplateArgumentList(
 TemplateArgumentListInfo , bool PartialTemplateArgs,
 SmallVectorImpl ,
 SmallVectorImpl ,
-bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied) {
+bool UpdateArgsWithConversions, bool *ConstraintsNotSatisfied,
+bool PartialOrderTTP) {
 
   if (ConstraintsNotSatisfied)
 *ConstraintsNotSatisfied = false;
@@ -6507,8