2016-08-12 10:21:25 +08:00
|
|
|
// No PCH:
|
|
|
|
// RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s
|
|
|
|
//
|
|
|
|
// With PCH:
|
2020-09-05 20:23:54 +08:00
|
|
|
// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors %s -o %t
|
|
|
|
// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s
|
2016-08-12 10:21:25 +08:00
|
|
|
|
2020-09-05 20:23:54 +08:00
|
|
|
// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors -fpch-instantiate-templates %s -o %t
|
|
|
|
// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s
|
2020-04-19 23:49:47 +08:00
|
|
|
|
2016-08-12 10:21:25 +08:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2020-09-05 20:23:54 +08:00
|
|
|
auto [noinit]; // expected-error{{decomposition declaration '[noinit]' requires an initializer}}
|
|
|
|
|
2016-08-12 10:21:25 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
int arr[2];
|
|
|
|
int k = decomp(arr);
|
|
|
|
|
|
|
|
static_assert(foo({1, 2}) == 12);
|
|
|
|
|
2020-04-19 23:49:47 +08:00
|
|
|
// expected-error@15 {{cannot decompose non-class, non-array type 'const int'}}
|
2016-08-12 10:21:25 +08:00
|
|
|
int z = decomp(10); // expected-note {{instantiation of}}
|
|
|
|
|
|
|
|
#endif
|