This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Better GCC diagnostics
On Fri, 15 Aug 2008, Ian Lance Taylor wrote:
> Perhaps I misunderstand what you mean by recording the location in the
> preprocessed token stream. You evidently do not mean getting column
> numbers for the preprocessed code. You mean that when a preprocessor
> macro is expanded, we should record both the location where the macro
> is used, and also some sort of reference to the macro so that we know
> the location where the macro was defined. Is that right?
My use case for locations in preprocessed code is tracking down
diagnostics arising in the expansions of complicated macros. I find
that's the main case where GCC's existing diagnostics are unhelpful; in
that case I would like an option to show the relevant fragment of
preprocessed source that causes the diagnostic. There are also easy
heuristics to decide whether the preprocessed source is likely to be more
useful than the non-preprocessed source.
Indexes into a table of tokens would be one possibility; C++ already
creates such a table in the course of lexing the whole input up front.
--
Joseph S. Myers
joseph@codesourcery.com