From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113160 invoked by alias); 3 Jun 2019 09:42:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 113152 invoked by uid 89); 3 Jun 2019 09:42:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-lj1-f196.google.com Received: from mail-lj1-f196.google.com (HELO mail-lj1-f196.google.com) (209.85.208.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jun 2019 09:42:30 +0000 Received: by mail-lj1-f196.google.com with SMTP id v29so4225693ljv.0 for ; Mon, 03 Jun 2019 02:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4AfY+a7V/pX2OW7hogHWvTw/488ddojjHz0ef18339o=; b=PjsY0jNnMbkA6q5oXIybYukz+xgv9x9N2rfgjdaCC/8LZ6J7AKKj5Kg0Q5PsFsXGqy dn5rbB7lZQgr9UsIWmYEYnIwHzzfMz5FyszClGUx/+xU+bi17jlY2CqthqWzCAwsRoga sVAQO7cmeyGlcvwZTR1biXvaNPd30+AnC6Vl6jjchCU1eB4kAkXnARNJ6Gxfox8jozrY vsxii+LqR3xY2G5cJ0tsz7atwTGip6EBf+G679UbaXz+EVDpwdGiyoVhcjQcOvR/WQuE xFkjSTlC9vo191yYsXUnWRwfYtvx1r5dHYPXR27lSty5IShZqDIaWperwp0IVrpU9ylO QQhQ== MIME-Version: 1.0 References: <46673e65-eefd-68d5-088b-1a9723a84a9c@gmail.com> <40f90d08-e1a2-c220-952f-35a8d3a11bf7@redhat.com> In-Reply-To: <40f90d08-e1a2-c220-952f-35a8d3a11bf7@redhat.com> From: Richard Biener Date: Mon, 03 Jun 2019 09:42:00 -0000 Message-ID: Subject: Re: [PATCH] correct the representation of ADDR_EXPR involving pointer to array [PR 90694] To: Jeff Law Cc: Martin Sebor , gcc-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-06/txt/msg00046.txt.bz2 On Fri, May 31, 2019 at 10:50 PM Jeff Law 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 (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