[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
Fri Oct 21 10:11:13 PDT 2022
erichkeane added a comment.
So I've been messing around with this a bit, and am somewhat confident that IsAtLeastAsConstrainedAs should just contain:
unsigned Depth1 = CalculateTemplateDepthForConstraints(*this, D1);
unsigned Depth2 = CalculateTemplateDepthForConstraints(*this, D2);
for (size_t I = 0; I != AC1.size() && I != AC2.size(); ++I) {
if (Depth2 > Depth1) {
AC1[I] = AdjustConstraintDepth(*this, Depth2 - Depth1).
TransformExpr(const_cast<Expr*>(AC1[I])).
get();
} else if (Depth1 > Depth2) {
AC2[I] = AdjustConstraintDepth(*this, Depth1 - Depth2).
TransformExpr(const_cast<Expr*>(AC2[I])).
get();
}
}
However, I see in the example:
template<typename T> concept C = T::f();
template<C> struct X{};
template<template<C> class P> struct S1 { }; // #S1
S1<X> s11;
That this fails because the type-constraint has already been instantiated during the SubstTemplateParams call ~5735 in SemaTemplate.cpp. I believe that to be an error, and the type-constraint on the TemplateTypeParmDecl should NOT be instantiated.
That line seems to change:
TemplateTypeParmDecl 0x149b2d20 <partb.cpp:4:19> col:20 Concept 0x149b2740 'C' depth 1 index 0
`-ConceptSpecializationExpr 0x149b2e58 <col:19> 'bool' Concept 0x149b2740 'C'
`-TemplateArgument <col:20> type 'type-parameter-1-0'
`-TemplateTypeParmType 0x149b2df0 'type-parameter-1-0' dependent depth 1 index 0
`-TemplateTypeParm 0x149b2d20 ''
To
TemplateTypeParmDecl 0x149d1550 <partb.cpp:4:19> col:20 Concept 0x149b2740 'C' depth 0 index 0
`-ConceptSpecializationExpr 0x149d1668 <col:19> 'bool' Concept 0x149b2740 'C'
`-TemplateArgument <col:20> type 'type-parameter-0-0'
`-TemplateTypeParmType 0x149d15f0 'type-parameter-0-0' dependent depth 0 index 0
`-TemplateTypeParm 0x149d1550 ''
While the `TemplateTypeParmDecl` is CORRECT to be changed like this, the `ConceptSpecializationExpr` should NOT have its arguments changed, thats the whole point of the deferred concepts implementation.
IN LOOKING, it seems that the problem is that the instantiator set up by `SubstTemplateParams` doesn't set the "EvaluateConstraints" to false, as it should be.
I did a test-patch here: https://reviews.llvm.org/D136468 (for you to look at, not for review!). However, I am getting 4 test failures that I suspect are a result of needing to stop evaluating constraints early elsewhere as well. I'm about done with being able to look at this today, so if you get a chance, you might find that useful to look into.
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