[clang] [Clang][RFC] Do not eat SFINAE diagnostics for explicit template arguments (PR #139066)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri May 8 04:44:23 PDT 2026


================
@@ -12166,6 +12174,15 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
              diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
           << (index + 1);
     }
+
+    if (PartialDiagnosticAt *PDiag = DeductionFailure.getSFINAEDiagnostic()) {
+      unsigned DiagID =
----------------
zyn0217 wrote:

Note that I managed to merge the additional notes into the previous `invalid explicitly-specified argument for 1st template parameter`, so the notes will look like

```cpp
test.cpp:4:3: error: no matching function for call to 'f'
    4 |   f<42>();
      |   ^~~~~
test.cpp:2:6: note: candidate template ignored: value of type 'int' is not implicitly convertible to 'int *' for 1st template parameter
    2 | void f();
      |      ^
1 error generated.
```

and it won't rely on the custom diagnostic id hack.

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


More information about the cfe-commits mailing list