From patchwork Tue Nov 16 15:14:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 47769 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 294DE385802B for ; Tue, 16 Nov 2021 15:15:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 294DE385802B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637075733; bh=GhvCTLeOYIeToOCIxwDfms5deFhceGVOoGQJTthQU1M=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=heD/yxepx6a3KyCDlmEJK3kNKjpR3Xo/fdCjzO3AmJ2Ftls0I87lsTtUZYAuQwnyz FPC38k5Qcvo87UkLglRCCsnsIdUgF9LOurIH7aCRpMQYznUk9/AgXNul26bc/WtCo0 H+4r3H/ZGHqvsDtgAUB+MeLEcHpAA067evjm/H2w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D0C543858D35 for ; Tue, 16 Nov 2021 15:15:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D0C543858D35 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-VyOgoprdN0eNkFtMHuOqMg-1; Tue, 16 Nov 2021 10:15:01 -0500 X-MC-Unique: VyOgoprdN0eNkFtMHuOqMg-1 Received: by mail-qk1-f199.google.com with SMTP id k18-20020a05620a07f200b00467e6cd54a2so12799448qkk.22 for ; Tue, 16 Nov 2021 07:15:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to; bh=0zCTb2cmtma2H5jSqHVEpvKko5/7DlwLSx0VIXRHvwM=; b=n9maapczjZZDft4C0epchjxOH3F+wvfntILo14dohSCTdAISm6dRjGXDvuHFAW59S1 r85ysqIQtxr5tc+IX02Hfnuh3xyiEDBnvHdzeIoDMSATn+yLJ2IAk4GoC0l8IbrV/e3S xNeIiVafqHSSt7oAugYK72v249nU6aEzacFvmfYlVTSXttDq3NL+0tQ1prRY17YnQ+SO qHOz/FOL0antl344LDP2XiqOj9SQB+Z4BJG3xBPq1H6gaMfCFlA6X2H7l4GXd75dke8c 963mz5rndXljbMR+B4jaQ4+5y2lAzXBcnqxncSMwHAd2fEhKjEJLA5mPYn0MYgxNwJLZ R5jg== X-Gm-Message-State: AOAM533E4xndEOHYoCHEynNKBxhm83O9+QCkEI9ky5mFDIA4nFTNmGEv 0QVQhBdcISd14ek5gBYkG6IRaV8DQPzVkbUfeEDqfFA76XA1XxcxVk9iAob3IgjbqidSryWgHz/ +sVY7OAOOmfeTbRIlEw== X-Received: by 2002:ac8:588a:: with SMTP id t10mr8563799qta.151.1637075700376; Tue, 16 Nov 2021 07:15:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZWMAzUphkTaIsJ55J0irLAFuLGe2LLf0Ut0tIOj0MkKh7Of5bpsC1SsuHVJDOZ14jRlbdBg== X-Received: by 2002:ac8:588a:: with SMTP id t10mr8563746qta.151.1637075700012; Tue, 16 Nov 2021 07:15:00 -0800 (PST) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id s12sm6443673qtk.61.2021.11.16.07.14.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Nov 2021 07:14:59 -0800 (PST) Message-ID: <1ac72e5d-bb8f-76c6-eac1-b78ff6d71c20@redhat.com> Date: Tue, 16 Nov 2021 10:14:55 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: [PATCH v2] c++: improve print_node of PTRMEM_CST To: Jakub Jelinek References: <20211104155234.1945303-1-jason@redhat.com> <20211104203251.GC304296@tucnak> In-Reply-To: <20211104203251.GC304296@tucnak> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On 11/4/21 16:32, Jakub Jelinek wrote: > On Thu, Nov 04, 2021 at 11:52:34AM -0400, Jason Merrill via Gcc-patches wrote: >> It's been inconvenient that pretty-printing of PTRMEM_CST didn't display >> what member the constant refers to. >> >> Adding that is complicated by the absence of a langhook for CONSTANT_CLASS_P >> nodes; the simplest fix for that is to use the tcc_exceptional hook for >> tcc_constant as well. >> >> Tested x86_64-pc-linux-gnu. OK for trunk, or should I add a new hook for >> constants? >> >> gcc/cp/ChangeLog: >> >> * ptree.c (cxx_print_xnode): Handle PTRMEM_CST. >> >> gcc/ChangeLog: >> >> * print-tree.c (print_node): Also call print_xnode hook for >> tcc_constant class. > > I think using the same langhook is fine, but in that case certainly > /* Called by print_tree when there is a tree of class tcc_exceptional > that it doesn't know how to display. */ > should be adjusted so that it mentions also tcc_constant. Done. > And maybe rename it from print_xnode to print_node? I think changing the comment is enough, it's still just exceptional and constant. This is what I'm pushing: From 761b128dbfa2fbc1f1a0138160a39db95db7759a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 29 Oct 2021 16:39:01 -0400 Subject: [PATCH] c++: improve print_node of PTRMEM_CST To: gcc-patches@gcc.gnu.org It's been inconvenient that pretty-printing of PTRMEM_CST didn't display what member the constant refers to. Adding that is complicated by the absence of a langhook for CONSTANT_CLASS_P nodes; the simplest fix for that is to use the tcc_exceptional hook for tcc_constant as well. gcc/cp/ChangeLog: * ptree.c (cxx_print_xnode): Handle PTRMEM_CST. gcc/ChangeLog: * langhooks.h (struct lang_hooks): Adjust comment. * print-tree.c (print_node): Also call print_xnode hook for tcc_constant class. --- gcc/langhooks.h | 2 +- gcc/cp/ptree.c | 3 +++ gcc/print-tree.c | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 3e89134e8b4..3db8f2a550d 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -477,7 +477,7 @@ struct lang_hooks void (*print_statistics) (void); /* Called by print_tree when there is a tree of class tcc_exceptional - that it doesn't know how to display. */ + or tcc_constant that it doesn't know how to display. */ lang_print_tree_hook print_xnode; /* Called to print language-dependent parts of tcc_decl, tcc_type, diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c index ca7884db39b..d514aa2cad2 100644 --- a/gcc/cp/ptree.c +++ b/gcc/cp/ptree.c @@ -379,6 +379,9 @@ cxx_print_xnode (FILE *file, tree node, int indent) if (tree message = STATIC_ASSERT_MESSAGE (node)) print_node (file, "message", message, indent+4); break; + case PTRMEM_CST: + print_node (file, "member", PTRMEM_CST_MEMBER (node), indent+4); + break; default: break; } diff --git a/gcc/print-tree.c b/gcc/print-tree.c index d1fbd044c27..b5dc523fcb1 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -1004,8 +1004,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent, break; default: - if (EXCEPTIONAL_CLASS_P (node)) - lang_hooks.print_xnode (file, node, indent); + lang_hooks.print_xnode (file, node, indent); break; } -- 2.27.0