summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp')
-rw-r--r--clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp b/clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp
new file mode 100644
index 00000000000..cd0518bfc59
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+int array() {
+ int arr[3] = {};
+ // FIXME: We are supposed to create an array object here and perform elementwise initialization.
+ auto [a, b, c] = arr; // expected-error {{cannot decompose non-class, non-array}}
+
+ auto &[d, e] = arr; // expected-error {{type 'int [3]' decomposes into 3 elements, but only 2 names were provided}}
+ auto &[f, g, h, i] = arr; // expected-error {{type 'int [3]' decomposes into 3 elements, but 4 names were provided}}
+
+ auto &[r0, r1, r2] = arr;
+ const auto &[cr0, cr1, cr2] = arr;
+
+ //static_assert(&arr[0] == &r0);
+ //static_assert(&arr[0] == &cr0);
+ using T = int;
+ using T = decltype(r0);
+ using U = const int;
+ using U = decltype(cr0);
+
+ return r1 + cr2;
+}
OpenPOWER on IntegriCloud