mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 16:56:35 +00:00
[Clang][P1061] Fix invalid pack binding crash (#135129)
This commit is contained in:
parent
a62b9b387f
commit
2f29829475
@ -4281,7 +4281,7 @@ public:
|
||||
[](BindingDecl *BD) { return BD->isParameterPack(); });
|
||||
|
||||
Bindings = Bindings.drop_front(BeforePackBindings.size());
|
||||
if (!Bindings.empty()) {
|
||||
if (!Bindings.empty() && Bindings.front()->getBinding()) {
|
||||
PackBindings = Bindings.front()->getBindingPackDecls();
|
||||
Bindings = Bindings.drop_front();
|
||||
}
|
||||
|
@ -1597,11 +1597,10 @@ Decl *TemplateDeclInstantiator::VisitDecompositionDecl(DecompositionDecl *D) {
|
||||
auto *NewDD = cast_if_present<DecompositionDecl>(
|
||||
VisitVarDecl(D, /*InstantiatingVarTemplate=*/false, &NewBindingArray));
|
||||
|
||||
if (!NewDD || NewDD->isInvalidDecl())
|
||||
if (!NewDD || NewDD->isInvalidDecl()) {
|
||||
for (auto *NewBD : NewBindings)
|
||||
NewBD->setInvalidDecl();
|
||||
|
||||
if (OldBindingPack) {
|
||||
} else if (OldBindingPack) {
|
||||
// Mark the bindings in the pack as instantiated.
|
||||
auto Bindings = NewDD->bindings();
|
||||
BindingDecl *NewBindingPack = *llvm::find_if(
|
||||
|
@ -3,9 +3,15 @@
|
||||
// RUN: %clang_cc1 -std=c++23 -verify=cxx23,nontemplate -fsyntax-only -Wc++26-extensions %s
|
||||
|
||||
void decompose_array() {
|
||||
int arr[4] = {1, 2, 3, 6};
|
||||
constexpr int arr[4] = {1, 2, 3, 6};
|
||||
// cxx26-warning@+3 {{structured binding packs are incompatible with C++ standards before C++2c}}
|
||||
// cxx23-warning@+2 {{structured binding packs are a C++2c extension}}
|
||||
// nontemplate-error@+1 {{pack declaration outside of template}}
|
||||
auto [x, ...rest, y] = arr;
|
||||
|
||||
// cxx26-warning@+4 {{structured binding packs are incompatible with C++ standards before C++2c}}
|
||||
// cxx23-warning@+3 {{structured binding packs are a C++2c extension}}
|
||||
// nontemplate-error@+2 {{decomposition declaration cannot be declared 'constexpr'}}
|
||||
// nontemplate-error@+1 {{pack declaration outside of template}}
|
||||
constexpr auto [x_c, ...rest_c, y_c] = arr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user