Richard Smith | 7b76d81 | 2016-08-12 02:21:25 +0000 | [diff] [blame] | 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 |