| 1 |
// RUN: %clang_cc1 -ast-dump -std=c++26 %s | FileCheck %s |
| 2 |
|
| 3 |
// Test this with PCH. |
| 4 |
// RUN: %clang_cc1 %s -std=c++26 -emit-pch -o %t %s |
| 5 |
// RUN: %clang_cc1 %s -std=c++26 -include-pch %t -ast-dump-all | FileCheck %s |
| 6 |
|
| 7 |
#ifndef PCH_HELPER |
| 8 |
#define PCH_HELPER |
| 9 |
|
| 10 |
template <unsigned N> |
| 11 |
void foo() { |
| 12 |
int arr[4] = {1, 2, 3, 4}; |
| 13 |
auto [binding_1, ...binding_rest, binding_4] = arr; |
| 14 |
int arr_2[] = {binding_rest...}; |
| 15 |
}; |
| 16 |
|
| 17 |
// CHECK-LABEL: FunctionTemplateDecl {{.*}} foo |
| 18 |
// CHECK-LABEL: BindingDecl {{.*}} binding_1 |
| 19 |
// CHECK-NEXT: ArraySubscriptExpr {{.*}} |
| 20 |
// CHECK-NEXT: ImplicitCastExpr |
| 21 |
// CHECK-NEXT: DeclRefExpr {{.*}} |
| 22 |
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 0 |
| 23 |
// CHECK-NOT: BindingDecl |
| 24 |
// CHECK-LABEL: BindingDecl {{.*}} binding_rest |
| 25 |
// CHECK-NEXT: FunctionParmPackExpr |
| 26 |
// CHECK-LABEL: BindingDecl {{.*}} binding_4 |
| 27 |
// CHECK-NEXT: ArraySubscriptExpr |
| 28 |
// CHECK-NEXT: ImplicitCastExpr {{.*}} |
| 29 |
// CHECK-NEXT: DeclRefExpr {{.*}} lvalue Decomposition {{.*}} |
| 30 |
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3 |
| 31 |
// CHECK-NOT: BindingDecl |
| 32 |
// CHECK-LABEL: VarDecl {{.*}} arr_2 |
| 33 |
// CHECK-NEXT: InitListExpr |
| 34 |
// CHECK-NEXT: PackExpansionExpr {{.*}} '<dependent type>' lvalue |
| 35 |
// CHECK-NEXT: DeclRefExpr {{.*}} lvalue Binding {{.*}} 'binding_rest' |
| 36 |
|
| 37 |
struct tag_t { }; |
| 38 |
template <unsigned N> |
| 39 |
void bar() { |
| 40 |
auto [...empty_binding_pack] = tag_t{}; |
| 41 |
static_assert(sizeof...(empty_binding_pack) == 0); |
| 42 |
}; |
| 43 |
|
| 44 |
// CHECK-LABEL: FunctionTemplateDecl {{.*}} bar |
| 45 |
// CHECK-NOT: BindingDecl |
| 46 |
// CHECK-LABEL: BindingDecl {{.*}} empty_binding_pack |
| 47 |
// CHECK-NEXT: FunctionParmPackExpr |
| 48 |
// CHECK: DeclStmt |
| 49 |
|
| 50 |
struct int_pair { int x; int y; }; |
| 51 |
template <typename T> |
| 52 |
void baz() { |
| 53 |
auto [binding_1, binding_2, ...empty_binding_pack] = T{}; |
| 54 |
static_assert(sizeof...(empty_binding_pack) == 0); |
| 55 |
}; |
| 56 |
|
| 57 |
void(*f)() = baz<int_pair>; |
| 58 |
|
| 59 |
// CHECK-LABEL: FunctionDecl {{.*}} baz {{.*}} implicit_instantiation |
| 60 |
// CHECK-NEXT: TemplateArgument type 'int_pair' |
| 61 |
// CHECK: BindingDecl {{.*}} binding_1 |
| 62 |
// CHECK: BindingDecl {{.*}} binding_2 |
| 63 |
// CHECK-NOT: BindingDecl |
| 64 |
// CHECK-LABEL: BindingDecl {{.*}} empty_binding_pack |
| 65 |
// CHECK-NEXT: FunctionParmPackExpr |
| 66 |
// CHECK: DeclStmt |
| 67 |
#endif |