summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/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/Parser/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/Parser/cxx1z-decomposition.cpp')
-rw-r--r--clang/test/Parser/cxx1z-decomposition.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/test/Parser/cxx1z-decomposition.cpp b/clang/test/Parser/cxx1z-decomposition.cpp
index 23e5775176d..c5651c56588 100644
--- a/clang/test/Parser/cxx1z-decomposition.cpp
+++ b/clang/test/Parser/cxx1z-decomposition.cpp
@@ -67,7 +67,7 @@ namespace BadSpecifiers {
// storage-class-specifiers
static auto &[a] = n; // expected-error {{cannot be declared 'static'}}
thread_local auto &[b] = n; // expected-error {{cannot be declared 'thread_local'}}
- extern auto &[c] = n; // expected-error {{cannot be declared 'extern'}}
+ extern auto &[c] = n; // expected-error {{cannot be declared 'extern'}} expected-error {{cannot have an initializer}}
struct S {
mutable auto &[d] = n; // expected-error {{not permitted in this context}}
@@ -97,7 +97,7 @@ namespace BadSpecifiers {
auto [e][1] = s; // expected-error {{expected ';'}} expected-error {{requires an initializer}}
// FIXME: This should fire the 'misplaced array declarator' diagnostic.
- int [K] arr = {0}; // expected-error {{expected ';'}} expected-error {{cannot be declared with type 'int'}}
+ int [K] arr = {0}; // expected-error {{expected ';'}} expected-error {{cannot be declared with type 'int'}} expected-error {{decomposition declaration '[K]' requires an initializer}}
int [5] arr = {0}; // expected-error {{place the brackets after the name}}
auto *[f] = s; // expected-error {{cannot be declared with type 'auto *'}} expected-error {{incompatible initializer}}
@@ -133,3 +133,16 @@ namespace Template {
// FIXME: There's no actual rule against this...
template<typename T> auto [a, b, c] = n; // expected-error {{decomposition declaration template not supported}}
}
+
+namespace Init {
+ void f() {
+ int arr[1];
+ struct S { int n; };
+ auto &[bad1]; // expected-error {{decomposition declaration '[bad1]' requires an initializer}}
+ const auto &[bad2](S{}); // expected-error {{decomposition declaration '[bad2]' cannot have a parenthesized initializer}}
+ auto &[good1] = arr;
+ auto &&[good2] = S{};
+ S [goodish3] = { 4 }; // expected-error {{cannot be declared with type 'S'}}
+ S [goodish4] { 4 }; // expected-error {{cannot be declared with type 'S'}}
+ }
+}
OpenPOWER on IntegriCloud