[PATCH] D149264: GH62362: Handle constraints on "Using" inherited constructors

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 26 17:18:31 PDT 2023


rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:138-144
+                        bool SkipForSpecialization,
+                        bool ForConstraintInstantiation) {
   if (!ClassTemplSpec->isClassScopeExplicitSpecialization()) {
     // We're done when we hit an explicit specialization.
     if (ClassTemplSpec->getSpecializationKind() == TSK_ExplicitSpecialization &&
-        !isa<ClassTemplatePartialSpecializationDecl>(ClassTemplSpec))
+        !isa<ClassTemplatePartialSpecializationDecl>(ClassTemplSpec) &&
+        !ForConstraintInstantiation)
----------------
rsmith wrote:
> It seems to me that a namespace-scope explicit specialization shouldn't pick up template arguments, even during constraint checking:
> 
> ```
> template<typename T> struct A {};
> template<> struct A<int> {
>   template<typename U> void f() requires U::value;
> };
> ```
> Constraint checking for `A<X>::f<Y>` should produce a single level of template arguments, `<Y>`, not two layers `<X>, <Y>`, because `U` in `U::value` is a depth-0 index-0 parameter.
Complete testcase:
```
struct X {}; struct Y { static constexpr bool value = true; };
template<typename T> struct A {};
template<> struct A<X> {                          
  template<typename U> void f() requires U::value;
};                                                                   
void g(A<X> a) { a.f<Y>(); }
```


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

https://reviews.llvm.org/D149264



More information about the cfe-commits mailing list