Re: [PATCH] regex: use C99-style array arg syntax

2021-08-27 Thread Paul Eggert
On 8/27/21 2:56 AM, Bruno Haible wrote: So, to make the __access__ attribute [1] really consistent, they would need to add a fifth access-mode 'any', that would not restrict the access pattern. Yes, something like that might make sense. I would suggest something more general, though, along th

Re: [PATCH] regex: use C99-style array arg syntax

2021-08-27 Thread Bruno Haible
Hi Paul, Thanks for the explanations. > any of the access modes 'read', 'write', > 'read_write', 'none' are incorrect for some valid and reasonable regexec > calls. So, to make the __access__ attribute [1] really consistent, they would need to add a fifth access-mode 'any', that would not rest

Re: [PATCH] regex: use C99-style array arg syntax

2021-08-27 Thread Paul Eggert
On 8/26/21 4:58 PM, Bruno Haible wrote: Oops, my suggestion was not right. Instead, what needs to be done in order to preserve good diagnostics with GCC 10 is to keep the __access__ attribute, even with the VLA. Yes, it appears I was too ambitious in my patch. I have reverted much of it and th

Re: [PATCH] regex: use C99-style array arg syntax

2021-08-26 Thread Bruno Haible
I wrote: > Paul Eggert wrote: > > +#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ > > + && !defined __STDC_NO_VLA__) > > +# define __ARG_NELTS(n) n > > +#else > > +# define __ARG_NELTS(n) > > +#endif > > I would suggest to add a condition __GNUC__ >= 11 in the #if. > > Rationa

Re: [PATCH] regex: use C99-style array arg syntax

2021-08-26 Thread Bruno Haible
Paul Eggert wrote: > +#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ > + && !defined __STDC_NO_VLA__) > +# define __ARG_NELTS(n) n > +#else > +# define __ARG_NELTS(n) > +#endif I would suggest to add a condition __GNUC__ >= 11 in the #if. Rationale: GCC version 10 provides rea

Re: [PATCH] regex: use C99-style array arg syntax

2021-08-26 Thread Bruno Haible
Paul Eggert wrote: > +/* Specify the number of elements of a function's array parameter, > + as in 'int f (int n, int a[__ARG_NELTS (n)]);'. */ > +#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ > + && !defined __STDC_NO_VLA__) > +# define __ARG_NELTS(n) n > +#else > +# define

[PATCH] regex: use C99-style array arg syntax

2021-08-26 Thread Paul Eggert
This should help with some static checking. Derived from a suggestion by Martin Sebor in: https://sourceware.org/pipermail/libc-alpha/2021-August/130336.html This also ports recent and relevant Glibc changes to Gnulib and prepares to copy back. * lib/cdefs.h (__ARG_NELTS): New macro. * lib/regex.c: