Re: [PATCH v15 4/4] c: Add __countof__ operator

2024-10-16 Thread Alejandro Colomar
Hi Joseph, On Wed, Oct 16, 2024 at 10:30:36AM GMT, Joseph Myers wrote: > On Wed, 16 Oct 2024, Alejandro Colomar wrote: > > > + if (type_code != ARRAY_TYPE) > > +{ > > + error_at (loc, "invalid application of % to type %qT", > > type); > > + return error_mark_node; > > +} > > +

Re: [PATCH v15 4/4] c: Add __countof__ operator

2024-10-16 Thread Joseph Myers
On Wed, 16 Oct 2024, Alejandro Colomar wrote: > + if (type_code != ARRAY_TYPE) > +{ > + error_at (loc, "invalid application of % to type %qT", type); > + return error_mark_node; > +} > + if (!COMPLETE_TYPE_P (type)) > +{ > + error_at (loc, > + "invalid appl

[PATCH v15 4/4] c: Add __countof__ operator

2024-10-16 Thread Alejandro Colomar
This operator is similar to sizeof but can only be applied to an array, and returns its number of elements. FUTURE DIRECTIONS: - We should make it work with array parameters to functions, and somehow magically return the number of elements of the array, regardless of it being really a poin