diff options
author | Qing Zhao <qing.zhao@oracle.com> | 2025-06-16 17:54:24 +0000 |
---|---|---|
committer | Qing Zhao <qing.zhao@oracle.com> | 2025-07-01 20:21:37 +0000 |
commit | 687727375769dd41971bad369f3553f1163b3e7a (patch) | |
tree | b8c99325c78095e80c1413aaf049256d2b58becb /gcc/rust/backend/rust-compile-struct-field-expr.h | |
parent | fc029f5d34168ca5d94f737ee5e013f9524c29b2 (diff) | |
download | gcc-687727375769dd41971bad369f3553f1163b3e7a.zip gcc-687727375769dd41971bad369f3553f1163b3e7a.tar.gz gcc-687727375769dd41971bad369f3553f1163b3e7a.tar.bz2 |
Extend "counted_by" attribute to pointer fields of structures. Convert a pointer reference with counted_by attribute to .ACCESS_WITH_SIZE.
For example:
struct PP {
size_t count2;
char other1;
char *array2 __attribute__ ((counted_by (count2)));
int other2;
} *pp;
specifies that the "array2" is an array that is pointed by the
pointer field, and its number of elements is given by the field
"count2" in the same structure.
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-typeck.cc (build_counted_by_ref): Handle pointers with counted_by.
Add one more argument, issue error when the pointee type is a structure
or union including a flexible array member.
(build_access_with_size_for_counted_by): Handle pointers with counted_by.
(handle_counted_by_for_component_ref): Call build_counted_by_ref
with the new prototype.
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.c: New test.
Diffstat (limited to 'gcc/rust/backend/rust-compile-struct-field-expr.h')
0 files changed, 0 insertions, 0 deletions