From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 19474388CC14 for ; Tue, 5 Jan 2021 23:17:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 19474388CC14 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-dYtrSXH_NMW3kH8fYMXJBQ-1; Tue, 05 Jan 2021 18:17:26 -0500 X-MC-Unique: dYtrSXH_NMW3kH8fYMXJBQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0970C1005504; Tue, 5 Jan 2021 23:17:25 +0000 (UTC) Received: from localhost.localdomain (ovpn-114-95.phx2.redhat.com [10.3.114.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id A397B173EA; Tue, 5 Jan 2021 23:17:24 +0000 (UTC) Subject: Re: [PATCH v3] handle MEM_REF with void* arguments (PR c++/95768) To: Martin Sebor , gcc-patches , Jason Merrill , Richard Biener References: <29c9b3fa-69a2-dca9-1477-54aac80c8680@gmail.com> <5b4805a5-1949-267c-dc40-6f084349a68b@gmail.com> <658215da-753d-8df6-4467-b43db150e5bd@gmail.com> <887c792e-ba8e-33ee-a607-dc4fbd8a1b8e@gmail.com> From: Jeff Law Message-ID: Date: Tue, 5 Jan 2021 16:17:24 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <887c792e-ba8e-33ee-a607-dc4fbd8a1b8e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jan 2021 23:17:30 -0000 On 1/2/21 3:22 PM, Martin Sebor via Gcc-patches wrote: > Attached is another revision of a patch I posted last July to keep > the pretty-printer from crashing on MEM_REFs with void* arguments: >   https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549746.html > > Besides avoiding the ICE and enhancing the MEM_REF detail and > improving its format, this revision implements the suggestions > in that discussion.  To avoid code duplication it moves > the handling to the C pretty-printer and changes the C++ front > end to delegate to it.  In addition, it includes a cast to > the accessed type if it's different from/incompatible with > (according to GIMPLE) that of the dereferenced pointer, or if > the object is typeless.  Lastly, it replaces the in > the output with either VLA names or the RHS of the GIMPLE > expression (this improves the output when for dynamically > allocated objects). > > As an aside, In my experience, MEM_REFs in warnings are limited > to -Wuninitialized.  I think other middle end warnings tend to > avoid them.  Those that involve invalid/out-of-bounds accesses > replace them with either the target DECL (e.g., local variable, > or FIELD_DECL), the allocation call (e.g., malloc), or the DECL > of the pointer (e.g., PARM_DECL), followed by a note mentioning > the offset into the object.  I'd like to change -Wuninitialized > at some point to follow the same style.  So I see the value of > the MEM_REF formatting enhancement mainly as a transient solution > until that happens. > > Martin > > gcc-95768.diff > > PR c++/95768 - pretty-printer ICE on -Wuninitialized with allocated storage > > gcc/c-family/ChangeLog: > > PR c++/95768 > * c-pretty-print.c (c_pretty_printer::primary_expression): For > SSA_NAMEs print VLA names and GIMPLE defining statements. > (print_mem_ref): New function. > (c_pretty_printer::unary_expression): Call it. > > gcc/cp/ChangeLog: > > PR c++/95768 > * error.c (dump_expr): Call c_pretty_printer::unary_expression. > > gcc/testsuite/ChangeLog: > > PR c++/95768 > * g++.dg/pr95768.C: New test. > * g++.dg/warn/Wuninitialized-12.C: New test. > * gcc.dg/uninit-38.c: New test. OK jeff