MSVC compatibility mode: fix error on unqualified templated base class initialization...
authorFred Tingaud <frederic-tingaud@sonarsource.com>
Tue, 16 Aug 2022 15:09:55 +0000 (17:09 +0200)
committerBalazs Benics <benicsbalazs@gmail.com>
Tue, 16 Aug 2022 15:09:55 +0000 (17:09 +0200)
commitba1c396e09a6dc56d817df0d378f3c826bbacaaa
treee6a847b0e19542704e87323b5d5c2a1ad741b019
parent451497a030d7f817d62472c13cb7c58a1c59995a
MSVC compatibility mode: fix error on unqualified templated base class initialization in case of partial specialization

I introduced a patch to handle unqualified templated base class
initialization in MSVC compatibility mode:
https://reviews.llvm.org/rGc894e85fc64dd8d83b460de81080fff93c5ca334
We identified a problem with this patch in the case where the base class
is partially specialized, which can lead to triggering an assertion in
the case of a mix between types and values.
The minimal test case is:

  template <typename Type, int TSize> class Vec {};
  template <int TDim> class Index : public Vec<int, TDim> {
    Index() : Vec() {}
  };
  template class Index<0>;

The detailed problem is that I was using the
`InjectedClassNameSpecialization`, to which the class template arguments
were then applied in order. But in the process, we were losing all the
partial specializations of the base class and creating an index mismatch
between the expected and passed arguments.

Patch By: frederic-tingaud-sonarsource

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D130709
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaTemplate/ms-unqualified-base-class.cpp