| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux -ast-print %s -o - | FileCheck %s |
| 2 |
|
| 3 |
typedef unsigned long int size_t; |
| 4 |
|
| 5 |
int global_array[42]; |
| 6 |
int global_int; |
| 7 |
|
| 8 |
struct fam_struct { |
| 9 |
int x; |
| 10 |
char count; |
| 11 |
int array[] __attribute__((counted_by(count))); |
| 12 |
}; |
| 13 |
|
| 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; |
| 19 |
|
| 20 |
*_Generic(__builtin_counted_by_ref(ptr->array), |
| 21 |
void *: &__ignored_assignment, |
| 22 |
default: __builtin_counted_by_ref(ptr->array)) = 42; // ok |
| 23 |
} |