[PATCH,c++] fix PR 45330, suggest alternatives for failed name lookups

Nathan Froyd froydnj@codesourcery.com
Mon Dec 6 19:00:00 GMT 2010


On Sun, Dec 05, 2010 at 10:07:56AM -0600, Mark Mitchell wrote:
> On 12/4/2010 5:16 PM, Jason Merrill wrote:
> > If you say %q+D in your error message, that means "use the locus of this
> > decl as well as printing it."  That seems a lot more concise than having
> > to write error_at (DECL_SOURCE_LOCATION (decl), "...%qD...", decl);
> 
> 100% agreed.  "%q+D" is a good thing.
> 
> On the other hand, I do also agree that using input_location is not a
> good thing; the locations for error messages should be driven by
> something explicit (a declaration, or something else).

Eh, so what's the desired way forward here?  AFAICS, the `+' modifier is
used only with `error' or `warning'.  But both of those functions use
input_location; if we want to get rid of input_location, it seems like
the easiest thing (along the way; surely this is not the only thing that
would be required) to do would be to excise `error' and `warning', use
their _at variants, remove the `+' modifiers from the diagnostic
strings, and use DECL_SOURCE_LOCATION or location_at or what have you at
the point of the call.  (You could do something like:

  perl -pi -e 's/(error|warning) \(/\1_at (UNKNOWN_LOCATION/g' **/*.c

or similar, but I hope you agree that would be really ugly.)

I agree that %q+D is concise, but the magicness of it is a little weird.

-Nathan



More information about the Gcc-patches mailing list