Debian Codegraph @

gcc/testsuite/gcc.dg/flex-array-counted-by-9.c

raw
1 /* PR c/116735 */
2 /* { dg-options "-std=c99" } */
3 /* { dg-do compile } */
4
5 struct foo {
6 int len;
7 int element[] __attribute__ ((__counted_by__ (lenx))); /* { dg-error "attribute is not a field declaration in the same structure as" } */
8 };
9
10 struct bar {
11 float count;
12 int array[] __attribute ((counted_by (count))); /* { dg-error "attribute is not a field declaration with an integer type" } */
13 };
14
15 int main ()
16 {
17 struct foo *p = __builtin_malloc (sizeof (struct foo) + 3 * sizeof (int));
18 struct bar *q = __builtin_malloc (sizeof (struct bar) + 3 * sizeof (int));
19 p->len = 3;
20 p->element[0] = 17;
21 p->element[1] = 13;
22 q->array[0] = 13;
23 q->array[2] = 17;
24 return 0;
25 }