Patch for %E formatting for C
Gabriel Dos Reis
gdr@cs.tamu.edu
Sun Oct 3 14:39:00 GMT 2004
"Joseph S. Myers" <jsm@polyomino.org.uk> writes:
| On Sun, 2 Oct 2004, Gabriel Dos Reis wrote:
|
| > that point C++ front-end would cease to pass plain IDENTIFIER_NODE
| > around -- I expect it will wrap them in something that is an
| > expression, otherwise the whole front-end will break :-).
| > And I also expect that, at that point, th C front-end wouold improve too.
|
| It has already improved in some places where identifiers could be confused
| with other trees (for example, declarators now wrap the identifier in a
| separate structure rather than having the IDENTIFIER_NODE itself represent
| an identifier as a declarator). There is indeed plenty more to do.
|
| > One could argue that the cases where the C front-end would need to
| > pass IDENTIFIER_NODE to the pretty-printer should be inexistant, and
| > it does then it contains a bug. If an IDENTIFIER_NODE is the name of
| > a _DECL, then pass that decl, not the identifier.
|
| There are many cases where %qs is presently used with IDENTIFIER_POINTER,
| where there is an identifier that does not correspond to a DECL. For
| example, all the instances of
|
| warning ("%qs attribute ignored", IDENTIFIER_POINTER (name));
|
| or the error
|
| error ("label %qs referenced outside of any function",
| IDENTIFIER_POINTER (name));
I think that poking at IDENTIFIER_POINTER is a bug, but that is the
point the C front-end is currently written. The C++ front-end has
none of those (and I missed one, then that is a bug :-)
A label is a decl (LABEL_DECL) so it should have been used with %E,
just like any other _DECL in such contexts. It seems that most of
those cases where " a clear use of %I" is advocated, there is a
misuse of IDENTIFIER_POINTER in the first place; those should have
referenced the real entity.
| - so there is a clear use for %qI for such cases, while others should
| become %qD, if a DECL can be identified (even if presently the name rather
Again, %qD does not does type the argument being passed, but *request*
a particular form printing; just like when you way %qE, you're requesting
pretty-printing as expression. The formats control how the nodes are
displayed.
| than the DECL is being passed to the relevant function). At the same time
| there is a clear use for %E for genuine expressions, and probably many C
| front end diagnostics could be improved by its use.
Agreed.
-- Gaby
More information about the Gcc-patches
mailing list