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. For every context except a member declaration, any structure or union defined in those declaration specifiers is a top-level structure or union. 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). -- Joseph S. Myers [email protected]
