comparison clang/test/PCH/cxx1z-decomposition.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 2e18cbf3894f
comparison
equal deleted inserted replaced
147:c2174574ed3a 150:1d019706d866
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 %s -o %t
6 // RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s
7
8 #ifndef HEADER
9 #define HEADER
10
11 template<typename T> auto decomp(const T &t) {
12 auto &[a, b] = t;
13 return a + b;
14 }
15
16 struct Q { int a, b; };
17 constexpr int foo(Q &&q) {
18 auto &[a, b] = q;
19 return a * 10 + b;
20 }
21
22 #else
23
24 int arr[2];
25 int k = decomp(arr);
26
27 static_assert(foo({1, 2}) == 12);
28
29 // expected-error@12 {{cannot decompose non-class, non-array type 'const int'}}
30 int z = decomp(10); // expected-note {{instantiation of}}
31
32 #endif