This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Support %N$/*N$ style format arguments in GCC diagnostics (take 2)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, gcc-patches at gcc dot gnu dot org
- Date: Sun, 5 Jun 2005 04:39:39 -0400
- Subject: Re: [PATCH] Support %N$/*N$ style format arguments in GCC diagnostics (take 2)
- References: <20050517113757.GD4930@devserv.devel.redhat.com> <Pine.LNX.email@example.com> <20050518170635.GB22344@sunsite.mff.cuni.cz> <Pine.LNX.firstname.lastname@example.org> <20050520193740.GC4930@devserv.devel.redhat.com> <email@example.com> <20050525175049.GD9038@devserv.devel.redhat.com> <firstname.lastname@example.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sat, Jun 04, 2005 at 02:34:58PM -0700, Zack Weinberg wrote:
> Jakub Jelinek <email@example.com> writes:
> > It doesn't seem to be much simpler, because it needs to play ugly games
> > with changing the pretty printer in place (passing a scratch printer
> > to the format decoder routine does not work, because the original
> > printer is usually embedded into some larger structure and relies on
> > the other fields). Anyway, I have implemented that below.
> Sorry for the delay getting back to you here. I do not understand the
> problem with passing a scratch printer, even after staring at the
> code. Could you expand a little?
Suppose you have a scratch printer in pretty-print.c:
static pretty_printer arg_printer;
initialized somewhere and suppose you pass it to the format decoder routine:
ok = pp_format_decoder (pp) (&arg_printer, text);
so that the string is printed to a separate obstack, isn't flushed to any
stream, wrapped etc.
Now, consider say C %D format. c_tree_printer does:
c_pretty_printer *cpp = (c_pretty_printer *) pp;
pp_c_expression (cpp, t);
typedef struct c_pretty_print_info c_pretty_printer;
/* Points to the first element of an array of offset-list.
Not used yet. */
/* These must be overridden by each of the C and C++ front-end to
reflect their understanding of syntactic productions when they differ. */
and pp_c_expression etc. use the various hooks in struct
c_pretty_print_info. But we passed &arg_printer to the format
decoder routine, so these fields contain garbage (something from objects