Diagnostic clean ups
Gabriel Dos Reis
gdr@codesourcery.com
Wed Jun 5 20:36:00 GMT 2002
Neil Booth <neil@daikokuya.demon.co.uk> writes:
| Gabriel Dos Reis wrote:-
|
| > In the near term, I would like to
| >
| > o get rid of redundant codes (mostly for
| > {error, warning, pedwarn}_with{decl, file_and_line}) -- for
| > this I'll introduce a format specifier (%H) for printing or
| > indicating a diagnostic 'location'.
| >
| > o have other forms of diagnostics (e.g. informative notes that are not
| > necessarily warnings or errors)
| >
| > o categoryzing diagnostics so that a simple grep can find them
| > (Error:, Warning:, Anachronism:, ... see diagnostic.def -- I
| > already have a patch for this one).
| >
| > For the mid term, I want to
| > o have diagnostics with carrets
|
| Cool. I'd like to see cpplib use diagnostic.*; possibly with the
| existing cpperror.c remaining for users of cpplib other than the
| compiler but not being linked into the compilers (i.e. cpperror.c
| provides sample diagnostic reporting routines suitable for a
| generic client, but the front ends link against diagnostic.c
| for everything).
I would like to see that too. In general, I would like to see much
more code sharing in the compiler, especially in the area of
diagnostic report machinery. I'll do the necessary cleanup -- I still
need to get rid of two or three symbols in order to meet your need.
| I'd like to reqest a new format specifier: something to indicate
| the argument is a cpp_token * and that the spelling is wanted.
| This is kludged all over the place at the moment. Maybe %k;
| I believe 't' and 'T' are taken already.
%T is taken by the C-family front-ends (at least by cc1 and cc1plus).
Cpplib can reserved anything not mentioned by the comments above
diagnostic.c:output_format and cp/error.c:cp_printer, ther are:
%d, %i: (signed) integer in base ten.
%u: unsigned integer in base ten.
%o: unsigned integer in base eight.
%x: unsigned integer in base sixteen.
%ld, %li, %lo, %lu, %lx: long versions of the above.
%c: character.
%s: string.
%%: `%'.
%*.s: a substring the length of which is specified by an integer.
%A function argument-list.
%C tree code.
%D declaration.
%E expression.
%F function declaration.
%L language as used in extern "lang".
%O binary operator.
%P function parameter whose position is indicated by an integer.
%Q assignment operator.
%T type.
%V cv-qualifier.
I'm planning to use %H to indicate location and %+ or %# are used by
the C++ front-end.
| Something to consider for your file and line stuff: it should
| be possible to specify a location by reference to a token.
Like the %+ game that cc1plus plays?
| I don't
| know if you saw the discussion on one of the lists I had with Zack
| about 2 wks ago, but if we move to the front end accepting tokens
| a logical line at a time, represented as an array of cpp_token**,
| (I think this is the right thing) then I would imagine the correct
| type for this would be cpp_token **.
I didn't follow that discussion, could you give me some references?
| Finally, given a token, it should also be possible to have the caret
| point to a given offset into that token's spelling. This is a little
| tricky as tokens can cross physical lines and trigraphs can be involved
| too; so cpplib needs to do it. It would not be useful for the
| front ends proper, but is useful in the lexer and c-lex.c (e.g. for
| pointing out the invalid escape sequence embedded in a string, or
| a bogus character in a preprocessing number when trying to value it
| in c-lex.c).
Aha, I see, I'll give it some thought and let you know what I come up
with.
-- Gaby
More information about the Gcc-patches
mailing list