Previously, Clang would incorrectly accept the following:
template<int N> struct A {}; struct B : A<0>, A<1> {}; template<int N> int f(A<N>); int main() { f(B()); }
The problem is that when considering the base classes of B, there are 2 possible ambiguous bases that could be deduced. Therefore, deduction ought to fail (temp.deduct.call p5).
There are 3 improvements that I want to make here as well:
- Introduce a TDK_AmbiguousBaseClasses so that this diagnostic isn't terrible.
- Reapply Richard's r267453, (with some modifications) which previously broke stdlibc++'s tuple implementation (PR27601, reverted in r270016). This refactors the handmade base class traversal I fixed here to instead use CXXRecordDecl::forallBases(), I believe that requiring matching number of arguments in the DeduceTemplateArguments at SemaTemplateDeduction.cpp:433 will fix it.
- A NFC patch to rename the 10 (!) overloads of DeduceTemplateArguments to have more descriptive names. These functions are *really* annoying to deal with because of that.
If it would be better to do a subset (or all) of these improvements here, I could always update the diff. Fixes PR28195.
Thanks!