[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / AST / ast-print-builtin-counted-by-ref.c
blobc0ff7515fc8208846683578197f7b2fdaaa94e5b
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux -ast-print %s -o - | FileCheck %s
3 typedef unsigned long int size_t;
5 int global_array[42];
6 int global_int;
8 struct fam_struct {
9 int x;
10 char count;
11 int array[] __attribute__((counted_by(count)));
14 // CHECK-LABEL: void test1(struct fam_struct *ptr, int size) {
15 // CHECK-NEXT: size_t __ignored_assignment;
16 // CHECK-NEXT: *_Generic(__builtin_counted_by_ref(ptr->array), void *: &__ignored_assignment, default: __builtin_counted_by_ref(ptr->array)) = 42;
17 void test1(struct fam_struct *ptr, int size) {
18 size_t __ignored_assignment;
20 *_Generic(__builtin_counted_by_ref(ptr->array),
21 void *: &__ignored_assignment,
22 default: __builtin_counted_by_ref(ptr->array)) = 42; // ok