[clang] [Clang][Sema] Ensure that the selected candidate for a member function explicit specialization is more constrained than all others (PR #101721)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 2 16:48:19 PDT 2024


================
@@ -7964,8 +7964,9 @@ NamedDecl *Sema::ActOnVariableDeclarator(
     D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
   } else {
     // If this is an explicit specialization of a static data member, check it.
-    if (IsMemberSpecialization && !IsVariableTemplateSpecialization &&
-        !NewVD->isInvalidDecl() && CheckMemberSpecialization(NewVD, Previous))
+    if (IsMemberSpecialization && !IsVariableTemplate &&
+        !IsVariableTemplateSpecialization && !NewVD->isInvalidDecl() &&
+        CheckMemberSpecialization(NewVD, Previous))
----------------
zygoloid wrote:

Hm, do we not want to do these checks for an explicit specialization of a member template? Or do we also do those checks somewhere else? For example, it looks like we would probably have been diagnosing this here previously:

```c++
template<typename T> struct A {
  template<typename U> static int b;
};
namespace N {
  template<> template<typename U> int A<int>::b;
}
```

Are we still properly diagnosing this?

https://github.com/llvm/llvm-project/pull/101721


More information about the cfe-commits mailing list