Joseph,

Thanks a lot for your review on patch #1 and #4.

Could you also take another look at patch #3: Use the counted_by attribute of 
pointers in array bound checker?

You have reviewed and approved the previous version, in this new version, the 
only difference compared 
with the previous one is:  to match call to .ACCESS_WITH_SIZE in IL:

In OLD IL, there is one more INDIRECT_REF wrapping the call to 
.ACCESS_WITH_SIZE;
In NEW IL, this additional INDIRECT_REF is deleted, i.e:

-   *.ACCESS_WITH_SIZE (&p->c, &p->b, 1, 0, -1, 0B)
+   .ACCESS_WITH_SIZE (p->c, &p->b, 1, 0, -1, 0B)

Others keep the exactly the same.

Thanks a lot.

Qing
> On Aug 7, 2025, at 16:30, Joseph Myers <josmy...@redhat.com> wrote:
> 
> 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