> On Dec 4, 2025, at 18:43, Joseph Myers <[email protected]> wrote:
> 
> On Thu, 4 Dec 2025, Qing Zhao wrote:
> 
>> However, where should we call the “verify_counted_by_attribute” for the 
>> above cases?
>> 
>> Looks like that inside “finish_struct” is not the correct place to do 
>> this check since at that time we don’t know whether this structure will 
>> be used on its own.
>> 
>> Only when we are sure that this anonymous structure is used on its own, 
>> we should call “verify_counted_by_attribute” for it.
>> 
>> So, where in C FE we should check for this? Any suggestions?
> 
> Maybe go through all the places that process declaration specifiers.

Inside the routine “grokdeclarator”, when call “build_decl” for VAR_DECL, 
checking whether the type of
the decl is an anonymous struct/union, if so, call 
“verify_counted_by_attribute” for this type. 

> For every context except a member declaration, any structure or union defined 
> in those declaration specifiers is a top-level structure or union.

How about when call “build_decl” for  “TYPE_DECL”, “PARM_DECL”, and 
“FUNCTION_DECL”?
Shall do the same as “VAR_DECL”?

>  In a 
> member declaration, you need to wait until the point where it's determined 
> whether it's a use of the anonymous structs and unions features (once the 
> member declarator or declarators have been processed as well).

You mean when call “build_decl” for “FIELD_DECL”, do the same thing? 

thanks.

Qing
> 
> -- 
> Joseph S. Myers
> [email protected]


Reply via email to