On 11/7/20 8:11 AM, Iain Sandoe wrote: > Hi, > > For Objective-C++/C, we cater for the possibility that a class interface > (@interface) might be preceded by prefix attributes. In the case of > Objective-C++, the reference implementation (a.k.a. clang) also allows > (and combines) prefix attributes that precede a linkage specification > (but only on a single decl). > > Some discussion with Nathan here: > https://gcc.gnu.org/pipermail/gcc/2020-October/234057.html > > The upshot is that clang’s behaviour is inconsistent (I can file a bug, > I guess) - but since what is “well-formed” for Objective-C is defined in > reality by what clang accepts - there is a body of code out there that > depends on the behaviour (some variant of Hyrum’s law, or corollary > to it, perhaps?). > > Inability to parse code including these patterns is blocking progress > in modernising GNU Objective-C.. so I need to find a way forward. > > The compromise made here is to accept the sequence when parsing > for Objective-C++, and to warn** that the attributes are discarded otherwise. > > This seems to me to be an improvement in diagnostics for regular C++ > (since it now says something pertinent to the actual problem and does > the 'same as usual' when encountering an unhandled attribute). > > Tested across the Darwin patch, and on x86_64-linux-gnu, > OK for master? > thanks > Iain > > ** trivially, that could be an error instead - but it seems we usually warn > for unrecognised attributes. > > —— commit message > > For Objective-C++, this combines prefix attributes from before and > after top level linkage specs. The "reference implementation" for > Objective-C++ allows this, and system headers depend on it. > > e.g. > > __attribute__((__deprecated__)) > extern "C" __attribute__((__visibility__("default"))) > @interface MyClass > ... > @end > > Would consider the list of prefix attributes to the interface for > MyClass to include both the visibility and deprecated ones. > > When we are compiling regular C++, this emits a warning and discards > any prefix attributes before a linkage spec. > > gcc/cp/ChangeLog: > > * parser.c (cp_parser_declaration): Unless we are compiling for > Ojective-C++, warn about and discard any attributes that prefix > a linkage specification.
Absolutely willing to trust your judgment on ObjC++. So, OK jeff