On Fri, 1 Aug 2025, Qing Zhao wrote:

> gcc/c-family/ChangeLog:
> 
>       * c-attribs.cc (handle_counted_by_attribute): Accept counted_by
>       attribute for pointer fields.
> 
> gcc/c/ChangeLog:
> 
>       * c-decl.cc (verify_counted_by_attribute): Change the 2nd argument
>       to a vector of fields with counted_by attribute. Verify all fields
>       in this vector.
>       (finish_struct): Collect all the fields with counted_by attribute
>       to a vector and pass this vector to verify_counted_by_attribute.
>       * c-tree.h (handle_counted_by_for_component_ref): New prototype of
>       handle_counted_by_form_component_ref.
>       * c-parser.cc (c_parser_postfix_expression): Call the new prototype
>       of handle_counted_by_for_component_ref.
>       * c-typeck.cc (default_function_array_read_conversion): Only generate
>       call to .ACCESS_WITH_SIZE for a pointer field when it's a read.
>       (convert_lvalue_to_rvalue): Likewise.
>       (default_conversion): Likewise.
>       (handle_counted_by_p): New routine.
>       (check_counted_by_attribute): New routine.
>       (build_counted_by_ref): Handle pointers with counted_by.
>       (build_access_with_size_for_counted_by): Handle pointers with 
> counted_by.
>       (handle_counted_by_for_component_ref): Add one more argument.
>       (build_component_ref): Call the new prototype of
>       handle_counted_by_for_component_ref.
> 
> gcc/ChangeLog:
> 
>       * doc/extend.texi: Extend counted_by attribute to pointer fields in
>       structures. Add one more requirement to pointers with counted_by
>         attribute.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/flex-array-counted-by.c: Update test.
>       * gcc.dg/pointer-counted-by-1.c: New test.
>       * gcc.dg/pointer-counted-by-2.c: New test.
>       * gcc.dg/pointer-counted-by-3.c: New test.
>       * gcc.dg/pointer-counted-by-8.c: New test.
>       * gcc.dg/pointer-counted-by-9.c: New test.
>       * gcc.dg/pointer-counted-by.c: New test.

This patch is OK.

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to