[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)
Aidan Goldfarb via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 29 11:29:15 PST 2025
================
@@ -11714,13 +11714,37 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
return;
}
- case TemplateDeductionResult::InvalidExplicitArguments:
+ case TemplateDeductionResult::InvalidExplicitArguments: {
assert(ParamD && "no parameter found for invalid explicit arguments");
- if (ParamD->getDeclName())
- S.Diag(Templated->getLocation(),
- diag::note_ovl_candidate_explicit_arg_mismatch_named)
- << ParamD->getDeclName();
- else {
+ if (ParamD->getDeclName()) {
----------------
AidanGoldfarb wrote:
Just added. A current message is like this:
```
template <typename T>
void case1(T value) {}
int main() {
case1<42>(42);
}
```
```
source.cpp:44:5: error: no matching function for call to 'case1'
44 | case1<42>(42);
source.cpp:41:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'T': expected a type, but got value '42' (of type 'int')
40 | template <typename T>
| ~~~~~~~~~~
41 | void case1(T value) {}
| ^
```
Perhaps it is a bit unclear having the highlight and caret on sequential lines, which both refer to the same function definition? If this format looks good I am happy to keep it, but I could foresee some confusion.
https://github.com/llvm/llvm-project/pull/122754
More information about the cfe-commits
mailing list