diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-12 02:21:25 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-12 02:21:25 +0000 |
commit | bcd0b9f9023b35616284426cc1e049c0a1232460 (patch) | |
tree | dbc18855aaf0f5fa3334dbdc12ea6e4744032a1a /test/PCH | |
parent | eb66e2ffe787658976e133ab9a69d0e9a9cf3ac5 (diff) |
P0217R3: serialization/deserialization support for c++17 decomposition declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278460 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/cxx1z-decomposition.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/PCH/cxx1z-decomposition.cpp b/test/PCH/cxx1z-decomposition.cpp new file mode 100644 index 0000000000..e033577162 --- /dev/null +++ b/test/PCH/cxx1z-decomposition.cpp @@ -0,0 +1,32 @@ +// No PCH: +// RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s +// +// With PCH: +// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch %s -o %t +// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s + +#ifndef HEADER +#define HEADER + +template<typename T> auto decomp(const T &t) { + auto &[a, b] = t; + return a + b; +} + +struct Q { int a, b; }; +constexpr int foo(Q &&q) { + auto &[a, b] = q; + return a * 10 + b; +} + +#else + +int arr[2]; +int k = decomp(arr); + +static_assert(foo({1, 2}) == 12); + +// expected-error@12 {{cannot decompose non-class, non-array type 'const int'}} +int z = decomp(10); // expected-note {{instantiation of}} + +#endif |