brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 340d5ea Raw
38 lines · cpp
1// No PCH:2// RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s3//4// With PCH:5// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors %s -o %t6// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s7 8// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fallow-pch-with-compiler-errors -fpch-instantiate-templates %s -o %t9// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -fallow-pch-with-compiler-errors -verify %s10 11#ifndef HEADER12#define HEADER13 14template<typename T> auto decomp(const T &t) {15  auto &[a, b] = t;16  return a + b;17}18 19struct Q { int a, b; };20constexpr int foo(Q &&q) {21  auto &[a, b] = q;22  return a * 10 + b;23}24 25auto [noinit]; // expected-error{{structured binding declaration '[noinit]' requires an initializer}}26 27#else28 29int arr[2];30int k = decomp(arr);31 32static_assert(foo({1, 2}) == 12);33 34// expected-error@15 {{cannot bind non-class, non-array type 'const int'}}35int z = decomp(10); // expected-note {{instantiation of}}36 37#endif38