mizvekov added inline comments.

================
Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:1643
 
-      return Param == Arg? Sema::TDK_Success : Sema::TDK_NonDeducedMismatch;
+      return ParDesug == ArgDesug ? Sema::TDK_Success
+                                  : Sema::TDK_NonDeducedMismatch;
----------------
mizvekov wrote:
> rsmith wrote:
> > This looks wrong to me: we should be comparing the types, not how they're 
> > written. `Context.hasSameType(Param, Arg)` (or 
> > `Context.hasSameUnqualifiedType(Param, Arg)` in the `TDF_IgnoreQualifiers` 
> > case) would be appropriate here.
> You are right, but the reason we don't get into any troubles here is because 
> this is dead code anyway, the non-dependent case will always be handled above 
> :)
> 
> Although perhaps, I wonder if we should dig down into non-dependent types 
> anyway, in case the types are too complex and it's not immediately obvious 
> what does not match, we could perhaps improve the diagnostic?
> 
> I will experiment a little bit with this idea.
Here are the results of this experiment:
```
error: 'note' diagnostics expected but not seen:
  File SemaCXX\cxx1z-noexcept-function-type.cpp Line 21: could not match 'void 
(I) noexcept(false)' (aka 'void (int) noexcept(false)') against 'void (int) 
noexcept'
error: 'note' diagnostics seen but not expected:
  File SemaCXX\cxx1z-noexcept-function-type.cpp Line 21: candidate template 
ignored: failed template argument deduction

error: 'note' diagnostics expected but not seen:
  File SemaCXX\deduced-return-type-cxx14.cpp Line 146: candidate template 
ignored: could not match 'auto ()' against 'int ()'
  File SemaCXX\deduced-return-type-cxx14.cpp Line 161: candidate template 
ignored: could not match 'auto ()' against 'void ()'
error: 'note' diagnostics seen but not expected:
  File SemaCXX\deduced-return-type-cxx14.cpp Line 146: candidate template 
ignored: could not match 'auto' against 'int'
  File SemaCXX\deduced-return-type-cxx14.cpp Line 161: candidate template 
ignored: could not match 'auto' against 'void'

error: 'note' diagnostics expected but not seen:
  File SemaCXX\pass-object-size.cpp Line 62 (directive at 
SemaCXX\pass-object-size.cpp:69): candidate address cannot be taken because 
parameter 1 has pass_object_size attribute
  File SemaCXX\pass-object-size.cpp Line 56 (directive at 
SemaCXX\pass-object-size.cpp:74): candidate address cannot be taken because 
parameter 1 has pass_object_size attribute
  File SemaCXX\pass-object-size.cpp Line 62 (directive at 
SemaCXX\pass-object-size.cpp:75): candidate address cannot be taken because 
parameter 1 has pass_object_size attribute
error: 'note' diagnostics seen but not expected:
  File SemaCXX\pass-object-size.cpp Line 56: candidate template ignored: failed 
template argument deduction
  File SemaCXX\pass-object-size.cpp Line 62: candidate template ignored: failed 
template argument deduction
  File SemaCXX\pass-object-size.cpp Line 62: candidate template ignored: failed 
template argument deduction

error: 'note' diagnostics expected but not seen:
  File SemaTemplate\deduction.cpp Line 316: deduced non-type template argument 
does not have the same type as the corresponding template parameter 
('std::nullptr_t' vs 'int *')
  File SemaTemplate\deduction.cpp Line 323: values of conflicting types
error: 'note' diagnostics seen but not expected:
  File SemaTemplate\deduction.cpp Line 275: candidate template ignored: could 
not match 'const int' against 'int'
  File SemaTemplate\deduction.cpp Line 316: candidate template ignored: could 
not match 'int *' against 'std::nullptr_t'
  File SemaTemplate\deduction.cpp Line 323: candidate template ignored: could 
not match 'int *' against 'std::nullptr_t'

error: 'note' diagnostics expected but not seen:
  File SemaTemplate\explicit-instantiation.cpp Line 64: candidate template 
ignored: could not match 'void ()' against 'void (float *)'
  File SemaTemplate\explicit-instantiation.cpp Line 70: candidate template 
ignored: could not match 'void (int *)' against 'void (float *)'
error: 'note' diagnostics seen but not expected:
  File SemaTemplate\explicit-instantiation.cpp Line 70: candidate template 
ignored: could not match 'int' against 'float'
  File SemaTemplate\explicit-instantiation.cpp Line 64: candidate template 
ignored: failed template argument deduction
```

It's interesting to note that it reveals several cases we give too generic 
'failed template argument deduction' errors, like the different noexcept 
specifications, function prototypes with different amount of parameters, and 
the 'pass_object_size attribute' case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to