[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 18 06:40:09 PDT 2022


erichkeane added a comment.

In D134128#3865063 <https://reviews.llvm.org/D134128#3865063>, @lime wrote:

>> which isn't clear to me what you mean
>
> - In the function `Sema::CheckTemplateArgument` at line 5725, `Params` has been substituted in a way all `TemplateTypeParmDecl`s are instantiated with a smaller depth, and so are constraints of them at SemaTemplateInstantiateDecl.cpp:2769, while the requires clause remains the same.
> - Then `CheckTemplateArgument` calls `CheckTemplateTemplateArgument` which calls `IsAtLeastAsConstrained` with the original declaration and the constraints collected from `Params`. Thus, in `IsAtLeastAsConstrained`, a depth calculated from the declaration will not reflect the depth in the constraint.
> - It should be fine to not adjust the depths between two constraints passed to `IsAtLeastAsConstrained` if the requires clause is not parsed, as they are already the same. But it is not the case when the constraint is from a requires clause, as requires clauses are not substituted. However, calculating from declarations will break the original case.

It sounds like perhaps we've instantiated constraints we shouldn't have in the case of template-template parameters.  Based on what you're saying, I'm concerned then that perhaps the deferred concept instantiation didn't work right for template-template constraints? That might require more work on that then before anything could happen here.

Otherwise, I would expect calculating from the Template Template Decl to work, (though its likely it doesn't actually 'add' a layer yet, since I don't think we've needed that yet, so an extra bit of work there would need to be done).

>> I wouldn't expect the requires clause (nor any other concept related AST node) to be instantiated at all until it is going through 'checking'
>
> The function `TemplateDeclInstantiator::SubstTemplateParams` instantiates constraints like `template <template <C T> class>`, so it is already happened.

If that is happening outside of a constraint evaluation, that is likely incorrect, and perhaps part of the problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134128/new/

https://reviews.llvm.org/D134128



More information about the cfe-commits mailing list