On Fri, May 31, 2019 at 10:50 PM Jeff Law <l...@redhat.com> wrote:
>
> On 5/31/19 1:56 PM, Martin Sebor wrote:
> > Given a poiner to array p, tree dumps for expressions like &(*p)[2]
> > actually show &*p[2].  That's not right -- the parentheses are
> > important to differentiate indexing into the array the pointer
> > points to from indexing into the pointer.
> >
> > The attached patch adjusts the tree pretty printer to add the parens
> > when the pointer points to an array.
> >
> > Tested on x86_64-linux.
> >
> > Martin
> >
> > gcc-90694.diff
> >
> > PR middle-end/90694 - incorrect representation of ADDR_EXPR involving a 
> > pointer to array
> >
> > gcc/ChangeLog:
> >
> >       PR middle-end/90694
> >       * tree-pretty-print.c (dump_generic_node): Add parentheses.
> >
> > gcc/testsuite/ChangeLog:
> >
> >       PR middle-end/90694
> >       * gcc.dg/tree-ssa/dump-5.c: New test.
> OK.  I'm going to assume that the gimple parser already does the right
> thing since it's supposed to already handle C expressions correctly.

-gimple dumping doesn't elide dumping MEM_REFs to plain * so you
see

  _1 = &__MEM <char[8]> (pa)[2];
  _2 = __builtin_strlen (_1);

I think the GIMPLE FE accepts *p as dereference in source, sth I
should eventually fix (it likewise accepts ->).  It then just does
what the C frontend does since it shares most of its parsing.

Richard.

> Jeff

Reply via email to