diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-11 22:25:46 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-11 22:25:46 +0000 |
| commit | 7873de0cf65f48e6c8169691ee7eb203b89bfac5 (patch) | |
| tree | 361febace1eab46aacfef2f710bf7720448f7f3a /clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp | |
| parent | fa7ae4f3b6316e60de4e3d9f4dd1f355889f970c (diff) | |
| download | bcm5719-llvm-7873de0cf65f48e6c8169691ee7eb203b89bfac5.tar.gz bcm5719-llvm-7873de0cf65f48e6c8169691ee7eb203b89bfac5.zip | |
P0217R3: Perform semantic checks and initialization for the bindings in a
decomposition declaration for arrays, aggregate-like structs, tuple-like
types, and (as an extension) for complex and vector types.
llvm-svn: 278435
Diffstat (limited to 'clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp')
| -rw-r--r-- | clang/test/CXX/dcl.decl/dcl.decomp/p2.cpp | 22 |
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; +} |

