[clang] [Clang] Check constraints for an explicit instantiation of a member function (PR #104438)

Mital Ashok via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 18 01:24:41 PDT 2024


================
@@ -5663,6 +5663,8 @@ def err_explicit_instantiation_internal_linkage : Error<
 def err_explicit_instantiation_not_known : Error<
   "explicit instantiation of %0 does not refer to a function template, "
   "variable template, member function, member class, or static data member">;
+def err_explicit_instantiation_no_candidate : Error<
+    "no candidate for explicit instantiation of %0">;
----------------
MitalAshok wrote:

There's notes in the example above, but yeah no reason to change everything in this PR when it seems unrelated.  
This message should say "no *viable* candidate" (or "no matching function").

Also you should be able to restructure stuff so that template/non template member functions can use the same overload set, so would naturally use the same diagnostic. For example, this:

```c++
template<typename>
struct A {
  template<typename = void>
  void f() requires(false);
  void f() requires(false);
};
template void A<int>::f();
```

Should note both candidates, when I think your change means it only notes the non-template candidate (and removing the non-template function means it notes the template one, which seems strange)

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


More information about the cfe-commits mailing list