blob: 880e17a9d3e2f993a73b55701aa15d3624c924bc [file] [edit]
// Without serialization:
// RUN: %clang_cc1 -std=c++26 -ast-print %s | FileCheck %s
//
// With serialization:
// RUN: %clang_cc1 -std=c++26 -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++26 -include-pch %t -ast-print /dev/null | FileCheck %s
#if 0 // Disabled until we support iterating expansion statements.
template <typename T, __SIZE_TYPE__ size>
struct Array {
T data[size]{};
constexpr const T* begin() const { return data; }
constexpr const T* end() const { return data + size; }
};
#endif // 0
// CHECK: void foo(int);
void foo(int);
// CHECK: template <typename T> void test(T t) {
template <typename T>
void test(T t) {
// Enumerating expansion statement.
//
// CHECK: template for (auto x : {1, 2, 3}) {
// CHECK-NEXT: foo(x);
// CHECK-NEXT: }
template for (auto x : {1, 2, 3}) {
foo(x);
}
#if 0 // Disabled until we support iterating expansion statements.
// Iterating expansion statement.
//
// NOTE: Remove 'DISABLED-' when the '#if 0' is removed.
// DISABLED-CHECK: static constexpr Array<int, 3> a;
// DISABLED-CHECK-NEXT: template for (auto x : (a)) {
// DISABLED-CHECK-NEXT: foo(x);
// DISABLED-CHECK-NEXT: }
static constexpr Array<int, 3> a;
template for (auto x : a) {
foo(x);
}
#endif // 0
// Destructuring expansion statement.
//
// CHECK: int arr[3]{1, 2, 3};
// CHECK-NEXT: template for (auto x : arr) {
// CHECK-NEXT: foo(x);
// CHECK-NEXT: }
int arr[3]{1, 2, 3};
template for (auto x : arr) {
foo(x);
}
// Dependent expansion statement.
//
// CHECK: template for (auto x : t) {
// CHECK-NEXT: foo(x);
// CHECK-NEXT: }
template for (auto x : t) {
foo(x);
}
}
// CHECK: template <typename T> void test2(T t) {
template <typename T>
void test2(T t) {
// Enumerating expansion statement.
//
// CHECK: template for (int x : {1, 2, 3}) {
// CHECK-NEXT: foo(x);
// CHECK-NEXT: }
template for (int x : {1, 2, 3}) {
foo(x);
}
#if 0 // Disabled until we support iterating expansion statements.
// Iterating expansion statement.
//
// NOTE: Remove 'DISABLED-' when the '#if 0' is removed.
// DISABLED-CHECK: static constexpr Array<int, 3> a;
// DISABLED-CHECK-NEXT: template for (int x : (a)) {
// DISABLED-CHECK-NEXT: foo(x);
// DISABLED-CHECK-NEXT: }
static constexpr Array<int, 3> a;
template for (int x : a) {
foo(x);
}
#endif // 0
// Destructuring expansion statement.
//
// CHECK: int arr[3]{1, 2, 3};
// CHECK-NEXT: template for (int x : arr) {
// CHECK-NEXT: foo(x);
// CHECK-NEXT: }
int arr[3]{1, 2, 3};
template for (int x : arr) {
foo(x);
}
// Dependent expansion statement.
//
// CHECK: template for (int x : t) {
// CHECK-NEXT: foo(x);
// CHECK-NEXT: }
template for (int x : t) {
foo(x);
}
}