On Mon, Nov 23, 2020 at 8:52 AM Iain Sandoe <i...@sandoe.co.uk> wrote:
> Jason Merrill <ja...@redhat.com> wrote: > > > On 11/7/20 10:11 AM, Iain Sandoe wrote: > > >> + warning_at (token1->location, OPT_Wattributes, "attributes > are" > >> + " only permitted in this position for > Objective-C++," > >> + " ignored"); > > > > It would be nice for the warning to suggest where to move the > attribute, > > rather than just say that this location is bad. > > f.C: > > __attribute__(()) > extern "C" int foo (void); > > === > > So, I looked at two possibles. > > 1/ trying to use a fixit hint - but this seems a little lacking in > information to me. > > f.C:2:1: warning: attributes are only permitted in this position for > Objective-C++ (ignored for C++) [-Wattributes] > 2 | __attribute__(()) > | ^~~~~~~~~~~~~ > 3 | extern "C" int foo (void); > | __attribute__ > > (NOTE: ‘__attribute__' starting indent is below ‘int’ for a fixed spacing > font) > > 2/ adding an inform: > > f.C:2:1: warning: attributes are only permitted in this position for > Objective-C++ (ignored for C++) [-Wattributes] > 2 | __attribute__(()) > | ^~~~~~~~~~~~~ > f.C:3:12: note: for C++, attributes may be added here > 3 | extern "C" int foo (void); > | ^~~ > > (NOTE: likewise, ^~~ starting indent is below ‘int’ for a fixed spacing > font) > > === > > I’m inclined to think that the second is more useful, > but have patches for both, > which (or something else) do you prefer? > I agree that the second is preferable, thanks. But let's not underline all of "int" there, just the caret is sufficient. I'd also drop the mention of Obj-C++. Jason