1 /* Test the attribute counted_by and its usage in
2 * __builtin_dynamic_object_size: when the counted_by field is negative. */
4 /* { dg-options "-O2" } */
6 #include "builtin-object-size-common.h"
10 int c
[] __attribute__ ((counted_by (b
)));
13 struct nested_annotated
{
21 int c
[] __attribute__ ((counted_by (b
)));
22 } *array_nested_annotated
;
24 void __attribute__((__noinline__
)) setup (int attr_count
)
27 = (struct annotated
*)malloc (sizeof (struct annotated
));
28 array_annotated
->b
= attr_count
;
30 array_nested_annotated
31 = (struct nested_annotated
*)malloc (sizeof (struct nested_annotated
));
32 array_nested_annotated
->b
= attr_count
-1;
37 void __attribute__((__noinline__
)) test ()
39 EXPECT(__builtin_dynamic_object_size(array_annotated
->c
, 1), 0);
40 EXPECT(__builtin_dynamic_object_size(array_nested_annotated
->c
, 1), 0);
43 int main(int argc
, char *argv
[])