On Thu, 13 Mar 2025, Jason Merrill wrote: > > I'd be afraid that would be quite significant change of behavior everywhere, > > something that C doesn't allow (like mixing std and GNU attributes in any > > orders or [[]] __attribute__(()) [[]][[]] __attribute__(()) > > expression-statement). Or it would allow __attribute__(()) on while, do, > > for, if, switch, ..., again something that wasn't accepted before. > > Do you think those changes are undesirable? We've previously had to fix cases > where we were failing to support mixing of std and GNU attributes.
Mixing attributes is problematic because of different semantics for appertainment. For example, in void func() ATTRS; if ATTRS are standard attributes then they are part of the function declarator and appertain to the function type, but if they are GNU attributes then they are not part of the declarator, but rather appertain to the declaration. This means completely different parts of the C parser handle the different kinds of attributes in what superficially looks like the same position (standard attributes handled in parsing a declarator, GNU ones in parsing the declaration after the declarator - with more complicated declarators such as functions returning pointers to arrays, the locations can end up physically separated) and there would be no coherent syntax or semantics for appertainment for mixed attributes there. -- Joseph S. Myers josmy...@redhat.com