18 lines · cpp
1// RUN: %clang_cc1 -std=c++26 -fsyntax-only %s -verify=nontemplate2// RUN: %clang_cc1 -std=c++2c -verify=cxx26,nontemplate -fsyntax-only -Wpre-c++26-compat %s3// RUN: %clang_cc1 -std=c++23 -verify=cxx23,nontemplate -fsyntax-only -Wc++26-extensions %s4 5void decompose_array() {6 constexpr int arr[4] = {1, 2, 3, 6};7 // cxx26-warning@+3 {{structured binding packs are incompatible with C++ standards before C++2c}}8 // cxx23-warning@+2 {{structured binding packs are a C++2c extension}}9 // nontemplate-error@+1 {{pack declaration outside of template}}10 auto [x, ...rest, y] = arr;11 12 // cxx26-warning@+4 {{structured binding packs are incompatible with C++ standards before C++2c}}13 // cxx23-error@+3 {{structured binding declaration cannot be declared 'constexpr'}}14 // cxx23-warning@+2 {{structured binding packs are a C++2c extension}}15 // nontemplate-error@+1 {{pack declaration outside of template}}16 constexpr auto [x_c, ...rest_c, y_c] = arr;17}18