This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fdump-ast-original and strg:
- From: Guillaume <guillaume dot thouvenin at polymtl dot ca>
- To: Joe Buck <jbuck at synopsys dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Fri, 30 Nov 2001 12:54:49 -0500 (EST)
- Subject: Re: fdump-ast-original and strg:
On Thu, 29 Nov 2001, Joe Buck wrote:
> Guillaume Thouvenin writes:
> ...
> > The problem is the following. If you have something like:
> >
> > -- part of a C code --
> >
> > fprintf(stderr, "error strg: toto");
> >
> > --
> >
> > The asg given by gcc gives the following line:
> >
> > @247 string_cst type: @268 strg: error strg: toto lngt: 5
> >
> > So, I add a very basic modification inside GCC (in c-dump.c) and now, it
> > produces this line:
> >
> > @247 string_cst type: @268 strg: "error strg: toto" lngt: 5
> >
> This seems reasonable, but does your patch do the whole job? What happens
> if the string contains newlines, control characters, or '"'? It would
> seem reasonable to make the output match the input (that is, output \",
> \n, etc).
No it doesn't do the whole job. If you have something like :
fprintf (stderr, "Hello\nit's a \"test\"\n");
It will produce :
@54 string_cst type: @67 strg: "Hello
it's a "test"
" lngt: 21
So, the good output should be
@54 string_cst type: @67 strg: "Hello\nit's a \"test\"\n"
lngt: 21
Actually, strings with newlines, control characters and '"' are treated by
my parser. The only modification that I done in GCC is in file c-dump.c:
line 649:
---
648: case STRING_CST:
649: fprintf (di->stream, "strg: \"%-7s\" ", TREE_STRING_POINTER (t));
^^ ^^
650: dump_int (di, "lngt", TREE_STRING_LENGTH (t));
651: break;
So, I can try to path GCC to make output match the input?
Guillaume