diff options
author | Krystian Stasiowski <sdkrystian@gmail.com> | 2024-10-30 12:50:40 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-30 14:50:40 -0400 |
commit | 90786adade22784a52856a0e8b545ec6710b47f6 (patch) | |
tree | a9df5f891632ee04de54813521059267f3d73d14 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 71b6f6b8a1cd9a63b9d382fe15f40bbb427939b9 (diff) | |
download | llvm-90786adade22784a52856a0e8b545ec6710b47f6.zip llvm-90786adade22784a52856a0e8b545ec6710b47f6.tar.gz llvm-90786adade22784a52856a0e8b545ec6710b47f6.tar.bz2 |
[Clang][Sema] Always use latest redeclaration of primary template (#114258)
This patch fixes a couple of regressions introduced in #111852.
Consider:
```
template<typename T>
struct A
{
template<bool U>
static constexpr bool f() requires U
{
return true;
}
};
template<>
template<bool U>
constexpr bool A<short>::f() requires U
{
return A<long>::f<U>();
}
template<>
template<bool U>
constexpr bool A<long>::f() requires U
{
return true;
}
static_assert(A<short>::f<true>()); // crash here
```
This crashes because when collecting template arguments from the _first_
declaration of `A<long>::f<true>` for constraint checking, we don't add
the template arguments from the enclosing class template specialization
because there exists another redeclaration that is a member
specialization.
This also fixes the following example, which happens for a similar
reason:
```
// input.cppm
export module input;
export template<int N>
constexpr int f();
template<int N>
struct A {
template<int J>
friend constexpr int f();
};
template struct A<0>;
template<int N>
constexpr int f() {
return N;
}
```
```
// input.cpp
import input;
static_assert(f<1>() == 1); // error: static assertion failed
```
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
0 files changed, 0 insertions, 0 deletions