Thanks for the comments.
> On Apr 10, 2024, at 13:35, Joseph Myers <[email protected]> wrote:
>
> On Fri, 29 Mar 2024, Qing Zhao wrote:
>
>> + /* Issue error when there is a counted_by attribute with a different
>> + field as the argument for the same flexible array member field. */
>
> There's another case of this to consider, though I'm not sure where best
> to check for it (Martin might have suggestions) - of course this case will
> need testcases as well.
Looks like this additional case relates to the new C23 feature, where is the
documentation on this new feature, I need to study a little bit on this, thanks.
>
> Suppose, as allowed in C23, a structure is defined twice in the same
> scope,
A stupid question first, the same scope means the same file? (Or same function)
Is there a testing case for this feature in current GCC source tree I can take
a look? (and
Then I can use it to construct the new testing case for the counted-by
attribute).
> but the two definitions of the structure use inconsistent
> counted_by attributes.
Where in the current C FE to handle the same structure is defined twice in the
same scope? Which routine
In the C FE?
> I'd say that, when the declarations are in the
> same scope (thus required to be consistent), it should be an error for the
> two definitions of what is meant to be the same structure to use
> incompatible counted_by attributes (even though the member declarations
> are otherwise the same).
Agreed. Wil add such checking.
>
> In C23 structures defined with the same tag in different scopes are
> compatible given requirements including compatible types for corresponding
> elements.
Again, which routine in the C FE handle such case? I’d like to take a look at
the current
Handling and how to update it for the counted-by attribute.
> It would seem most appropriate to me for such structures with
> incompatible counted_by attributes to be considered *not* compatible types
Is there a utility routine for checking “compatible type”?
> (but it would be valid to define structures with the same tag, different
> scopes, and elements the same except for counted_by - just not to use them
> in any way requiring them to be compatible).
Updating that routine (checking compatible type) with the new “counted-by”
attribute
Might be enough for this purpose, I guess.
>
>> +The @code{counted_by} attribute may be attached to the C99 flexible array
>> +member of a structure. It indicates that the number of the elements of the
>> +array is given by the field "@var{count}" in the same structure as the
>
> As noted previously, the "" quotes should be removed there (or replaced by
> ``'' quotes).
Okay, will update this.
thanks.
Qing
>
> --
> Joseph S. Myers
> [email protected]
>