This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR46745
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Wed, 1 Dec 2010 19:12:54 +0300 (MSK)
- Subject: Re: [PATCH] Fix PR46745
- References: <alpine.LNX.2.00.1012011510340.23074@zhemvz.fhfr.qr>
On Wed, 1 Dec 2010, Richard Guenther wrote:
>
> This teaches the C pretty printer about MEM_REF. I'm not sure how
> to best present the case with a non-constant offset to the user
"non-zero offset"?
> though (the patch prints *(p+byte offset)), printing a byte offset
> isn't equivalent to C semantics when the pointed to type of p isn't
> of size 1. I thought of printing an ellipsis in the non-constant
> offset case, *(...). Or going the full way and printing a cast,
> *(TREE_TYPE(mem) *)((char *)p + byte offset). But I'm not sure
> how fancy we should try to be for the late diagnostic cases.
I'd suggest ((type *) p)[k] when offset is divisible by type size and
((type *) (p + m))[k] otherwise (where k is offset / size, and p is implicitly
assumed to be 'char*').
Actually, I'm more concerned about the similar issue in the tree dumps than in
diagnostics. I would prefer something like the above in the dumps because
some day I (or someone else) might forget that MEM_REF gives a byte offset and
misinterpret the dump. If that's OK for you I can prepare a patch for
tree-pretty-print.c
My 2c.
Alexander