> On Jun 15, 2023, at 6:48 PM, Joseph Myers <jos...@codesourcery.com> wrote: > > On Thu, 15 Jun 2023, Qing Zhao via Gcc-patches wrote: > >> B. The argument of the new attribute “counted_by” is an identifier that can >> be >> accepted by “c_parser_attribute_arguments”: >> >> struct trailing_array_B { >> Int count; >> int array_B[] __attribute ((counted_by (count))); >> }; >> >> >> From my current very limited understanding of the C FE source code, it’s >> not easy to extend the argument to an expression later for the above. Is >> this understanding right? > > It wouldn't be entirely compatible: if you change to interpreting the > argument as an expression, then the above would suggest a global variable > count is used (as opposed to some other syntax for referring to an element > of the containing structure).
Yeah, that’s the reason I tried to introduce the new “.count” syntax for the argument of the new attribute in the very beginning in order to avoid such incompatible issue later. -:) > > So an attribute that takes an element name might best be a *different* > attribute from any potential future one taking an expression (with some > new syntax to refer to an element). So, if we add this “counted_by (identifier)” attribute now, and later we need to add another new attribute “new_counted_by (expression)” at that time if needed? Kees, what’s your opinion on this? thanks. Qing > > -- > Joseph S. Myers > jos...@codesourcery.com