]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: rewrite implementation of `arg spec' attribute
authorMartin Uecker <uecker@tugraz.at>
Sun, 27 Jul 2025 15:58:14 +0000 (17:58 +0200)
committerMartin Uecker <uecker@gcc.gnu.org>
Sat, 2 Aug 2025 07:06:49 +0000 (09:06 +0200)
commit09a3da82125e07da504136841d577f103aa4ea13
treed384009ac1cf8d61e5388d8c627e98560a49d9d3
parent3e4ced9de1f1c6444eae44c1fed493742c345bc6
c: rewrite implementation of `arg spec' attribute

Rewrite the implementation of the `arg spec' attribute to pass the the
original type of an array parameter instead of passing a string description
and a list of bounds.  The string and list are then created
from this type during the integration of the information of `arg spec'
into the access attribute because it still needed later for various
warnings.  This change makes the implementation simpler and more robust
as the declarator is not processed and information that is already encoded
in the type is not duplicated.  A similar change to the access attribute
could then completely remove the string processing.  With this change, the
original type is now available and can be used for other warnings or for
_Countof.  The new implementation tries to be faithful to the original,
but this is not entirely true as it fixes a bug in the old implementation.

gcc/c-family/ChangeLog:
* c-attribs.cc (handle_argspec_attribute): Update.
(build_arg_spec): New function.
(build_attr_access_from_parms): Rewrite `arg spec' handling.

gcc/c/ChangeLog:
* c-decl.cc (get_parm_array_spec): Remove.
(push_parm_decl): Do not add `arg spec` attribute.
(build_arg_spec_attribute): New function.
(grokdeklarator): Add `arg spec` attribute.

gcc/testsuite/ChangeLog:
* gcc.dg/Warray-parameter-11.c: Change Warray-parameter to
-Wvla-parameter as these are VLAs.
* gcc.dg/Warray-parameter.c: Remove xfail.
gcc/c-family/c-attribs.cc
gcc/c/c-decl.cc
gcc/testsuite/gcc.dg/Warray-parameter-11.c
gcc/testsuite/gcc.dg/Warray-parameter.c