xref: /llvm-project/clang/test/Parser/cxx2c-binding-pack.cpp (revision abc8812df02599fc413d9ed77b992f8236ed2af9)
1 // RUN: %clang_cc1 -std=c++2c -verify -fsyntax-only %s
2 
3 template <unsigned N>
4 void decompose_array() {
5   int arr[4] = {1, 2, 3, 5};
6   auto [x, ... // #1
7     rest, ...more_rest] = arr; // expected-error{{multiple packs in structured binding declaration}}
8                                // expected-note@#1{{previous binding pack specified here}}
9 
10   auto [y...] = arr; // expected-error{{'...' must immediately precede declared identifier}}
11 
12   auto [...] = arr; // #2
13                     // expected-error@#2{{expected identifier}}
14                     // expected-error@#2{{{no names were provided}}}
15                     // expected-warning@#2{{{does not allow a decomposition group to be empty}}}
16   auto [a, ..., b] = arr; // #3
17                           // expected-error@#3{{expected identifier}}
18                           // expected-error@#3{{{only 1 name was provided}}}
19   auto [a1, ...] = arr; // #4
20                         // expected-error@#4{{expected identifier}}
21                         // expected-error@#4{{{only 1 name was provided}}}
22   auto [..., b] = arr; // #5
23                        // expected-error@#5{{expected identifier}}
24                        // expected-error@#5{{{no names were provided}}}
25 }
26