summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx1z-decomposition.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-08-11 22:25:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-08-11 22:25:46 +0000
commit7873de0cf65f48e6c8169691ee7eb203b89bfac5 (patch)
tree361febace1eab46aacfef2f710bf7720448f7f3a /clang/test/SemaCXX/cxx1z-decomposition.cpp
parentfa7ae4f3b6316e60de4e3d9f4dd1f355889f970c (diff)
downloadbcm5719-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/SemaCXX/cxx1z-decomposition.cpp')
-rw-r--r--clang/test/SemaCXX/cxx1z-decomposition.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index 53434771ac7..6541476a67b 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -4,7 +4,23 @@ void use_from_own_init() {
auto [a] = a; // expected-error {{binding 'a' cannot appear in the initializer of its own decomposition declaration}}
}
-// FIXME: create correct bindings
+// As a Clang extension, _Complex can be decomposed.
+float decompose_complex(_Complex float cf) {
+ auto [re, im] = cf;
+ //static_assert(&re == &__real cf);
+ //static_assert(&im == &__imag cf);
+ return re*re + im*im;
+}
+
+// As a Clang extension, vector types can be decomposed.
+typedef float vf3 __attribute__((ext_vector_type(3)));
+float decompose_vector(vf3 v) {
+ auto [x, y, z] = v;
+ auto *p = &x; // expected-error {{address of vector element requested}}
+ return x + y + z;
+}
+
+// FIXME: by-value array copies
// FIXME: template instantiation
// FIXME: ast file support
// FIXME: code generation
OpenPOWER on IntegriCloud