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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 84DAA3858D39 for ; Tue, 19 Sep 2023 17:01:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84DAA3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695142881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=44evnTzdD3ddfGOxQFbS2AvLgzTQ7+Q8htp7nG8Z5PI=; b=WvaHZk+xXIhRB98XM4GKTpyOmMHYnW7NoNdwX4j09aaYGAoWKZxBc8Pd6ff5SCHApkeQ5n 5abllnxeld1ulOl9hzNQTMnZWKftZKXU7Hzfh4+AmupPSX/V1WL0EtYTbDT+Ebqb8hR6MJ 5kpQqRUBr5BNO1kSf6hXlBNHjddoxj4= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-hE22KEg1MqGG50zS_uGIqw-1; Tue, 19 Sep 2023 13:01:19 -0400 X-MC-Unique: hE22KEg1MqGG50zS_uGIqw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6561b118866so64928556d6.0 for ; Tue, 19 Sep 2023 10:01:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695142879; x=1695747679; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=44evnTzdD3ddfGOxQFbS2AvLgzTQ7+Q8htp7nG8Z5PI=; b=QepC0hmaPIwpS75vws8t2ZhmZO5uMxftma09LmlkrDMwX1N6/ZU5FlLKMIbsOkSUnm 8m0LkuDdyWxwQFVWlTU0UYiBykFOxpxnTADftzsI7Vt8WQP/f66SgGf5y4cEiIey5EcJ 0PI/SIj9C6osDn1VFZjtyy5PXHTKpiyf3Z4O8mSu/eD0r1984XGY77MCGJgOf1IFM2sA HNll9PSA1RVMwNtdaEZ3+xWICigcbcf3X2YJQu3J+mmisX68qBh7ckpdptxQls8sGJPu M2OeBmYV0/+UOAV2t653CLq6RQsScg8M5DKdbWZGjHfa8Aj4Prjpy14Q+8Ua3rgSR1co Cwsg== X-Gm-Message-State: AOJu0Yw3BO7r8IxuUYCX1iaShMBIMkYr6+NoELpFS9XXU8sLyxuEa3Qp VljVW9fVuIhDRHgGPc7jPESg8GT5lYtcTeJ/y+YF6DcvnrV6KRBhK1+/fbAKb4UV63pENa3LQQS FQZqofwo/H97T+kewhQ== X-Received: by 2002:a05:6214:4b12:b0:641:8b09:98ac with SMTP id pj18-20020a0562144b1200b006418b0998acmr14128283qvb.37.1695142879141; Tue, 19 Sep 2023 10:01:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9EbYdmV5QPWTbRz/wmjZNT1EXXGL9Xnu6lt3d7iT/2k4QOUvfI+qv3D1aVCyDs+694OtSrw== X-Received: by 2002:a05:6214:4b12:b0:641:8b09:98ac with SMTP id pj18-20020a0562144b1200b006418b0998acmr14128239qvb.37.1695142878555; Tue, 19 Sep 2023 10:01:18 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id bu13-20020ad455ed000000b00655e4f57732sm4332096qvb.35.2023.09.19.10.01.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Sep 2023 10:01:17 -0700 (PDT) Message-ID: Date: Tue, 19 Sep 2023 13:01:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] c++: improve class NTTP object pretty printing [PR111471] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20230919164055.728094-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20230919164055.728094-1-ppalka@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 9/19/23 12:40, Patrick Palka wrote: > Tested on x86_64-pc-linux-gnu, does this look OK for trunk/13? OK for trunk. What's your argument for backporting? > -- >8 -- > > 1. Move class NTTP object pretty printing to a more general spot in > the pretty printer. > 2. Print the type of an class NTTP object alongside its CONSTRUCTOR > value, like dump_expr would have done. > 3. Don't pretty print const VIEW_CONVERT_EXPR wrapping class NTTPs. > > PR c++/111471 > > gcc/cp/ChangeLog: > > * cxx-pretty-print.cc (cxx_pretty_printer::expression) > : Print the value of a class NTTP object. > : Strip cosnt VIEW_CONVERT_EXPR > wrappers for class NTTPs. > (pp_cxx_template_argument_list): Don't handle the class > NTTP objects here. > > gcc/testsuite/ChangeLog: > > * g++.dg/concepts/diagnostic19.C: New test. > --- > gcc/cp/cxx-pretty-print.cc | 19 +++++++++++++++++-- > gcc/testsuite/g++.dg/concepts/diagnostic19.C | 20 ++++++++++++++++++++ > 2 files changed, 37 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/concepts/diagnostic19.C > > diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc > index 909a9dc917f..7cd43151592 100644 > --- a/gcc/cp/cxx-pretty-print.cc > +++ b/gcc/cp/cxx-pretty-print.cc > @@ -1121,6 +1121,15 @@ cxx_pretty_printer::expression (tree t) > t = OVL_FIRST (t); > /* FALLTHRU */ > case VAR_DECL: > + if (DECL_NTTP_OBJECT_P (t)) > + { > + /* Print the type followed by the CONSTRUCTOR value of an > + NTTP object. */ > + simple_type_specifier (cv_unqualified (TREE_TYPE (t))); > + expression (DECL_INITIAL (t)); > + break; > + } > + /* FALLTHRU */ > case PARM_DECL: > case FIELD_DECL: > case CONST_DECL: > @@ -1261,6 +1270,14 @@ cxx_pretty_printer::expression (tree t) > pp_cxx_right_paren (this); > break; > > + case VIEW_CONVERT_EXPR: > + if (TREE_CODE (TREE_OPERAND (t, 0)) == TEMPLATE_PARM_INDEX) > + { > + /* Strip const VIEW_CONVERT_EXPR wrappers for class NTTPs. */ > + expression (TREE_OPERAND (t, 0)); > + break; > + } > + /* FALLTHRU */ > default: > c_pretty_printer::expression (t); > break; > @@ -1966,8 +1983,6 @@ pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t) > if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL > && TYPE_P (DECL_TEMPLATE_RESULT (arg)))) > pp->type_id (arg); > - else if (VAR_P (arg) && DECL_NTTP_OBJECT_P (arg)) > - pp->expression (DECL_INITIAL (arg)); > else > pp->expression (arg); > } > diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic19.C b/gcc/testsuite/g++.dg/concepts/diagnostic19.C > new file mode 100644 > index 00000000000..20cdb63380b > --- /dev/null > +++ b/gcc/testsuite/g++.dg/concepts/diagnostic19.C > @@ -0,0 +1,20 @@ > +// Verify our pretty printing of class NTTP objects. > +// PR c++/111471 > +// { dg-do compile { target c++20 } } > + > +struct A { bool value; }; > + > +template > + requires (V.value) // { dg-message {'\(V\).value \[with V = A\{false\}\]'} } > +void f(); > + > +template struct B { static constexpr auto value = V.value; }; > + > +template > + requires T::value // { dg-message {'T::value \[with T = B\]'} } > +void g(); > + > +int main() { > + f(); // { dg-error "no match" } > + g>(); // { dg-error "no match" } > +}