https://gcc.gnu.org/g:1aa755f51ab8b8c2bbd7e3cddd1c5a0369d84004
commit r16-3510-g1aa755f51ab8b8c2bbd7e3cddd1c5a0369d84004 Author: Jonathan Wakely <jwak...@redhat.com> Date: Sun Aug 31 10:46:36 2025 +0100 doc: Fix sort order for counted_by attribute gcc/ChangeLog: * doc/extend.texi (Common Variable Attributes): Put counted_by in alphabetical order. Diff: --- gcc/doc/extend.texi | 158 ++++++++++++++++++++++++++-------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 17e6311813ec..3c11928fd764 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -7140,6 +7140,85 @@ align them on any target. The @code{aligned} attribute can also be used for functions (@pxref{Common Function Attributes}.) +@cindex @code{alloc_size} variable attribute +@item alloc_size (@var{position}) +@itemx alloc_size (@var{position-1}, @var{position-2}) +The @code{alloc_size} variable attribute may be applied to the declaration +of a pointer to a function that returns a pointer and takes at least one +argument of an integer type. It indicates that the returned pointer points +to an object whose size is given by the function argument at @var{position}, +or by the product of the arguments at @var{position-1} and @var{position-2}. +Meaningful sizes are positive values less than @code{PTRDIFF_MAX}. Other +sizes are diagnosed when detected. GCC uses this information to improve +the results of @code{__builtin_object_size}. + +For instance, the following declarations + +@smallexample +typedef __attribute__ ((alloc_size (1, 2))) void* + (*calloc_ptr) (size_t, size_t); +typedef __attribute__ ((alloc_size (1))) void* + (*malloc_ptr) (size_t); +@end smallexample + +@noindent +specify that @code{calloc_ptr} is a pointer of a function that, like +the standard C function @code{calloc}, returns an object whose size +is given by the product of arguments 1 and 2, and similarly, that +@code{malloc_ptr}, like the standard C function @code{malloc}, +returns an object whose size is given by argument 1 to the function. + +@cindex @code{cleanup} variable attribute +@item cleanup (@var{cleanup_function}) +The @code{cleanup} attribute runs a function when the variable goes +out of scope. This attribute can only be applied to auto function +scope variables; it may not be applied to parameters or variables +with static storage duration. The function must take one parameter, +a pointer to a type compatible with the variable. The return value +of the function (if any) is ignored. + +When multiple variables in the same scope have @code{cleanup} +attributes, at exit from the scope their associated cleanup functions +are run in reverse order of definition (last defined, first +cleanup). + +If @option{-fexceptions} is enabled, then @var{cleanup_function} +is run during the stack unwinding that happens during the +processing of the exception. Note that the @code{cleanup} attribute +does not allow the exception to be caught, only to perform an action. +It is undefined what happens if @var{cleanup_function} does not +return normally. + +@cindex @code{common} variable attribute +@cindex @code{nocommon} variable attribute +@opindex fcommon +@opindex fno-common +@item common +@itemx nocommon +The @code{common} attribute requests GCC to place a variable in +``common'' storage. The @code{nocommon} attribute requests the +opposite---to allocate space for it directly. + +These attributes override the default chosen by the +@option{-fno-common} and @option{-fcommon} flags respectively. + +@cindex @code{copy} variable attribute +@item copy +@itemx copy (@var{variable}) +The @code{copy} attribute applies the set of attributes with which +@var{variable} has been declared to the declaration of the variable +to which the attribute is applied. The attribute is designed for +libraries that define aliases that are expected to specify the same +set of attributes as the aliased symbols. The @code{copy} attribute +can be used with variables, functions or types. However, the kind +of symbol to which the attribute is applied (either varible or +function) must match the kind of symbol to which the argument refers. +The @code{copy} attribute copies only syntactic and semantic attributes +but not attributes that affect a symbol's linkage or visibility such as +@code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated} +attribute is also not copied. @xref{Common Function Attributes}. +@xref{Common Type Attributes}. + @cindex @code{counted_by} variable attribute @item counted_by (@var{count}) The @code{counted_by} attribute may be attached to the C99 flexible array @@ -7243,85 +7322,6 @@ in @code{p->array}. Note, however, the above feature is not valid for the pointer field. -@cindex @code{alloc_size} variable attribute -@item alloc_size (@var{position}) -@itemx alloc_size (@var{position-1}, @var{position-2}) -The @code{alloc_size} variable attribute may be applied to the declaration -of a pointer to a function that returns a pointer and takes at least one -argument of an integer type. It indicates that the returned pointer points -to an object whose size is given by the function argument at @var{position}, -or by the product of the arguments at @var{position-1} and @var{position-2}. -Meaningful sizes are positive values less than @code{PTRDIFF_MAX}. Other -sizes are diagnosed when detected. GCC uses this information to improve -the results of @code{__builtin_object_size}. - -For instance, the following declarations - -@smallexample -typedef __attribute__ ((alloc_size (1, 2))) void* - (*calloc_ptr) (size_t, size_t); -typedef __attribute__ ((alloc_size (1))) void* - (*malloc_ptr) (size_t); -@end smallexample - -@noindent -specify that @code{calloc_ptr} is a pointer of a function that, like -the standard C function @code{calloc}, returns an object whose size -is given by the product of arguments 1 and 2, and similarly, that -@code{malloc_ptr}, like the standard C function @code{malloc}, -returns an object whose size is given by argument 1 to the function. - -@cindex @code{cleanup} variable attribute -@item cleanup (@var{cleanup_function}) -The @code{cleanup} attribute runs a function when the variable goes -out of scope. This attribute can only be applied to auto function -scope variables; it may not be applied to parameters or variables -with static storage duration. The function must take one parameter, -a pointer to a type compatible with the variable. The return value -of the function (if any) is ignored. - -When multiple variables in the same scope have @code{cleanup} -attributes, at exit from the scope their associated cleanup functions -are run in reverse order of definition (last defined, first -cleanup). - -If @option{-fexceptions} is enabled, then @var{cleanup_function} -is run during the stack unwinding that happens during the -processing of the exception. Note that the @code{cleanup} attribute -does not allow the exception to be caught, only to perform an action. -It is undefined what happens if @var{cleanup_function} does not -return normally. - -@cindex @code{common} variable attribute -@cindex @code{nocommon} variable attribute -@opindex fcommon -@opindex fno-common -@item common -@itemx nocommon -The @code{common} attribute requests GCC to place a variable in -``common'' storage. The @code{nocommon} attribute requests the -opposite---to allocate space for it directly. - -These attributes override the default chosen by the -@option{-fno-common} and @option{-fcommon} flags respectively. - -@cindex @code{copy} variable attribute -@item copy -@itemx copy (@var{variable}) -The @code{copy} attribute applies the set of attributes with which -@var{variable} has been declared to the declaration of the variable -to which the attribute is applied. The attribute is designed for -libraries that define aliases that are expected to specify the same -set of attributes as the aliased symbols. The @code{copy} attribute -can be used with variables, functions or types. However, the kind -of symbol to which the attribute is applied (either varible or -function) must match the kind of symbol to which the argument refers. -The @code{copy} attribute copies only syntactic and semantic attributes -but not attributes that affect a symbol's linkage or visibility such as -@code{alias}, @code{visibility}, or @code{weak}. The @code{deprecated} -attribute is also not copied. @xref{Common Function Attributes}. -@xref{Common Type Attributes}. - @cindex @code{deprecated} variable attribute @item deprecated @itemx deprecated (@var{msg})