1 | // RUN: %clang_cc1 -std=c++1z -verify %s -Wpedantic |
2 | |
3 | struct X { |
4 | X(int); |
5 | X(const X&) = delete; |
6 | }; |
7 | |
8 | int array() { |
9 | static int arr[3] = {}; |
10 | auto [a, b, c] = arr; |
11 | static_assert(&a != &arr[0]); |
12 | |
13 | using I3 = int[3]; |
14 | auto [a2, b2, c2] = I3{1, 2, 3}; |
15 | |
16 | using X3 = X[3]; |
17 | auto [a3, b3, c3] = X3{1, 2, 3}; |
18 | |
19 | auto &[d, e] = arr; // expected-error {{type 'int [3]' decomposes into 3 elements, but only 2 names were provided}} |
20 | auto &[f, g, h, i] = arr; // expected-error {{type 'int [3]' decomposes into 3 elements, but 4 names were provided}} |
21 | |
22 | auto &[r0, r1, r2] = arr; |
23 | const auto &[cr0, cr1, cr2] = arr; |
24 | |
25 | static_assert(&arr[0] == &r0); |
26 | static_assert(&arr[0] == &cr0); |
27 | |
28 | using T = int; |
29 | using T = decltype(r0); |
30 | using U = const int; |
31 | using U = decltype(cr0); |
32 | |
33 | return r1 + cr2; |
34 | } |
35 | |