1 // No PCH:
2 // RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s
3 //
4 // With PCH:
5 // RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors %s -o %t
6 // RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s
7
8 // RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors -fpch-instantiate-templates %s -o %t
9 // RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s
10
11 #ifndef HEADER
12 #define HEADER
13
decomp(const T & t)14 template<typename T> auto decomp(const T &t) {
15 auto &[a, b] = t;
16 return a + b;
17 }
18
19 struct Q { int a, b; };
foo(Q && q)20 constexpr int foo(Q &&q) {
21 auto &[a, b] = q;
22 return a * 10 + b;
23 }
24
25 auto [noinit]; // expected-error{{decomposition declaration '[noinit]' requires an initializer}}
26
27 #else
28
29 int arr[2];
30 int k = decomp(arr);
31
32 static_assert(foo({1, 2}) == 12);
33
34 // expected-error@15 {{cannot decompose non-class, non-array type 'const int'}}
35 int z = decomp(10); // expected-note {{instantiation of}}
36
37 #endif
38