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.133.124]) by sourceware.org (Postfix) with ESMTPS id D39643838214 for ; Tue, 31 May 2022 19:05:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D39643838214 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-230-y3X3_UGtNFyXgSeNSU6aJA-1; Tue, 31 May 2022 15:05:20 -0400 X-MC-Unique: y3X3_UGtNFyXgSeNSU6aJA-1 Received: by mail-qt1-f200.google.com with SMTP id u2-20020ac80502000000b002f94701339eso12939535qtg.13 for ; Tue, 31 May 2022 12:05:20 -0700 (PDT) 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:references:from:in-reply-to :content-transfer-encoding; bh=vwmo8tyK7ESIrcXxhzKzynp5Ist7rZGN8tAQaE0U69s=; b=CsoyUNQz4fbx6KRHc1Ys4L0YLBG1/Zg8x8wUP2IFVCh5o5jb73pvQ0gCqM9Nqc/Vlx 9kBr6d272tMEQqdJDX1Xv6rbF1v8RLmKd9xU4CvjXynmYuz9hLHJ4n6rIjAPsG2WIqEg qBZOLlcUZGLGLQxmJQVROnZlLs3lD/5DTDfCXHXnhlQoudsaao7hEeSkCNob1WPD352E 0Wb8Da0Ze3ZvpU/ncwfkVqCn24cMNcMXjWroCdoUUetOZUwDqlx7Pdh9R5+HWVkz1frw HDik68O4kOSWBm62UaT/AAfJC4es+RyRremP7nvL5Bz9QYrhOjWjL+iHP/aadu22xbp7 O1OA== X-Gm-Message-State: AOAM531Kc3aQog50NIdVbWSbVSH8HtW8b34gIkGRd+wd3u5u9WQm9hro XHMoTxlatc2oevwbFAaWR6B7Qzl+CJqk6cdE8VRIRwzmjBCrk6HHvaZ73k8P+2f+a6DQ5M38x2Z kG9x9HAp+wTgiz5gkWg== X-Received: by 2002:ac8:7d4b:0:b0:2f3:e185:efd4 with SMTP id h11-20020ac87d4b000000b002f3e185efd4mr49396726qtb.392.1654023919302; Tue, 31 May 2022 12:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYod2kb12iMAYWY1aofH1MWgFKl8RSCrNjgd/tmWEPl4tSaCXXPcGnF6arqfzVpYBQkpvHWw== X-Received: by 2002:ac8:7d4b:0:b0:2f3:e185:efd4 with SMTP id h11-20020ac87d4b000000b002f3e185efd4mr49396693qtb.392.1654023918892; Tue, 31 May 2022 12:05:18 -0700 (PDT) Received: from [192.168.1.100] (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 bz11-20020a05622a1e8b00b002f940c06d93sm928295qtb.16.2022.05.31.12.05.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 May 2022 12:05:18 -0700 (PDT) Message-ID: Date: Tue, 31 May 2022 15:05:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] c++: squash cp_build_qualified_type/_real To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20220531171308.131365-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20220531171308.131365-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=-14.0 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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, 31 May 2022 19:05:23 -0000 On 5/31/22 13:13, Patrick Palka wrote: > This replaces the two differently named versions of the same function > with a single function using a default function argument. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK > for trunk? OK. > gcc/cp/ChangeLog: > > * cp-tree.h (cp_build_qualified_type_real): Rename to ... > (cp_build_qualified_type): ... this. Give its last parameter > a default argument. Remove macro of the same name. > * decl.cc (grokdeclarator): Adjust accordingly. > * pt.cc (tsubst_aggr_type): Likewise. > (rebuild_function_or_method_type): Likewise. > (tsubst): Likewise. > (maybe_dependent_member_ref): Likewise. > (unify): Likewise. > * tree.cc (cp_build_qualified_type_real): Rename to ... > (cp_build_qualified_type): ... this. Adjust accordingly. > --- > gcc/cp/cp-tree.h | 5 ++--- > gcc/cp/decl.cc | 2 +- > gcc/cp/pt.cc | 52 ++++++++++++++++++++++++------------------------ > gcc/cp/tree.cc | 11 ++++------ > 4 files changed, 33 insertions(+), 37 deletions(-) > > diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h > index da8898155e0..cc13809f38a 100644 > --- a/gcc/cp/cp-tree.h > +++ b/gcc/cp/cp-tree.h > @@ -7877,9 +7877,8 @@ extern tree make_ptrmem_cst (tree, tree); > extern tree cp_build_type_attribute_variant (tree, tree); > extern tree cp_build_reference_type (tree, bool); > extern tree move (tree); > -extern tree cp_build_qualified_type_real (tree, int, tsubst_flags_t); > -#define cp_build_qualified_type(TYPE, QUALS) \ > - cp_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error) > +extern tree cp_build_qualified_type (tree, int, > + tsubst_flags_t = tf_warning_or_error); > extern bool cv_qualified_p (const_tree); > extern tree cv_unqualified (tree); > extern special_function_kind special_function_p (const_tree); > diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc > index 663a72fae15..e0d397d5a07 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -12375,7 +12375,7 @@ grokdeclarator (const cp_declarator *declarator, > type = DECL_ORIGINAL_TYPE (TYPE_NAME (type)); > > type_quals |= cp_type_quals (type); > - type = cp_build_qualified_type_real > + type = cp_build_qualified_type > (type, type_quals, ((((typedef_decl && !DECL_ARTIFICIAL (typedef_decl)) > || declspecs->decltype_p) > ? tf_ignore_bad_quals : 0) | tf_warning_or_error)); > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index 4a3f38b1f5a..759f119abc2 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -13767,7 +13767,7 @@ tsubst_aggr_type (tree t, > { > r = lookup_template_class (t, argvec, in_decl, context, > entering_scope, complain); > - r = cp_build_qualified_type_real (r, cp_type_quals (t), complain); > + r = cp_build_qualified_type (r, cp_type_quals (t), complain); > } > > return r; > @@ -13963,7 +13963,7 @@ rebuild_function_or_method_type (tree t, tree return_type, tree arg_types, > { > tree r = TREE_TYPE (TREE_VALUE (arg_types)); > /* Don't pick up extra function qualifiers from the basetype. */ > - r = cp_build_qualified_type_real (r, type_memfn_quals (t), complain); > + r = cp_build_qualified_type (r, type_memfn_quals (t), complain); > if (! MAYBE_CLASS_TYPE_P (r)) > { > /* [temp.deduct] > @@ -15651,7 +15651,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > if (r) > { > r = TREE_TYPE (r); > - r = cp_build_qualified_type_real > + r = cp_build_qualified_type > (r, cp_type_quals (t) | cp_type_quals (r), > complain | tf_ignore_bad_quals); > return r; > @@ -15661,8 +15661,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > /* We don't have an instantiation yet, so drop the typedef. */ > int quals = cp_type_quals (t); > t = DECL_ORIGINAL_TYPE (decl); > - t = cp_build_qualified_type_real (t, quals, > - complain | tf_ignore_bad_quals); > + t = cp_build_qualified_type (t, quals, > + complain | tf_ignore_bad_quals); > } > } > > @@ -15809,7 +15809,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > > quals = cp_type_quals (arg) | cp_type_quals (t); > > - return cp_build_qualified_type_real > + return cp_build_qualified_type > (arg, quals, complain | tf_ignore_bad_quals); > } > else if (code == BOUND_TEMPLATE_TEMPLATE_PARM) > @@ -15874,7 +15874,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > DECL_CONTEXT (arg), > /*entering_scope=*/0, > complain); > - return cp_build_qualified_type_real > + return cp_build_qualified_type > (r, cp_type_quals (t) | cp_type_quals (r), complain); > } > else if (code == TEMPLATE_TEMPLATE_PARM) > @@ -15909,7 +15909,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > if (cp_type_quals (t)) > { > r = tsubst (TYPE_MAIN_VARIANT (t), args, complain, in_decl); > - r = cp_build_qualified_type_real > + r = cp_build_qualified_type > (r, cp_type_quals (t), > complain | (code == TEMPLATE_TYPE_PARM > ? tf_ignore_bad_quals : 0)); > @@ -16079,7 +16079,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > TYPE_REF_IS_RVALUE (t) && TYPE_REF_IS_RVALUE (type)); > else > r = cp_build_reference_type (type, TYPE_REF_IS_RVALUE (t)); > - r = cp_build_qualified_type_real (r, cp_type_quals (t), complain); > + r = cp_build_qualified_type (r, cp_type_quals (t), complain); > > if (r != error_mark_node) > /* Will this ever be needed for TYPE_..._TO values? */ > @@ -16125,13 +16125,13 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > = build_memfn_type (type, r, type_memfn_quals (type), > type_memfn_rqual (type)); > memptr = build_ptrmemfunc_type (build_pointer_type (method_type)); > - return cp_build_qualified_type_real (memptr, cp_type_quals (t), > - complain); > + return cp_build_qualified_type (memptr, cp_type_quals (t), > + complain); > } > else > - return cp_build_qualified_type_real (build_ptrmem_type (r, type), > - cp_type_quals (t), > - complain); > + return cp_build_qualified_type (build_ptrmem_type (r, type), > + cp_type_quals (t), > + complain); > } > case FUNCTION_TYPE: > case METHOD_TYPE: > @@ -16282,7 +16282,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > } > } > > - return cp_build_qualified_type_real > + return cp_build_qualified_type > (f, cp_type_quals (f) | cp_type_quals (t), complain); > } > > @@ -16316,10 +16316,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > --c_inhibit_evaluation_warnings; > > type = finish_typeof (type); > - return cp_build_qualified_type_real (type, > - cp_type_quals (t) > - | cp_type_quals (type), > - complain); > + return cp_build_qualified_type (type, > + cp_type_quals (t) > + | cp_type_quals (type), > + complain); > } > > case DECLTYPE_TYPE: > @@ -16355,10 +16355,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) > id = false; > type = finish_decltype_type (type, id, complain); > } > - return cp_build_qualified_type_real (type, > - cp_type_quals (t) > - | cp_type_quals (type), > - complain | tf_ignore_bad_quals); > + return cp_build_qualified_type (type, > + cp_type_quals (t) > + | cp_type_quals (type), > + complain | tf_ignore_bad_quals); > } > > case UNDERLYING_TYPE: > @@ -16858,8 +16858,8 @@ maybe_dependent_member_ref (tree t, tree args, tsubst_flags_t complain, > decl = maybe_dependent_member_ref (decl, args, complain, in_decl); > if (!decl) > return NULL_TREE; > - return cp_build_qualified_type_real (TREE_TYPE (decl), cp_type_quals (t), > - complain); > + return cp_build_qualified_type (TREE_TYPE (decl), cp_type_quals (t), > + complain); > } > > tree name = DECL_NAME (t); > @@ -24231,7 +24231,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, > > /* Consider the case where ARG is `const volatile int' and > PARM is `const T'. Then, T should be `volatile int'. */ > - arg = cp_build_qualified_type_real > + arg = cp_build_qualified_type > (arg, cp_type_quals (arg) & ~cp_type_quals (parm), tf_none); > if (arg == error_mark_node) > return unify_invalid (explain_p); > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc > index 09162795801..2b9cb7e1c7b 100644 > --- a/gcc/cp/tree.cc > +++ b/gcc/cp/tree.cc > @@ -1359,9 +1359,8 @@ c_build_qualified_type (tree type, int type_quals, tree /* orig_qual_type */, > in a similar manner for restricting non-pointer types. */ > > tree > -cp_build_qualified_type_real (tree type, > - int type_quals, > - tsubst_flags_t complain) > +cp_build_qualified_type (tree type, int type_quals, > + tsubst_flags_t complain /* = tf_warning_or_error */) > { > tree result; > int bad_quals = TYPE_UNQUALIFIED; > @@ -1378,9 +1377,7 @@ cp_build_qualified_type_real (tree type, > type. Obtain the appropriately qualified element type. */ > tree t; > tree element_type > - = cp_build_qualified_type_real (TREE_TYPE (type), > - type_quals, > - complain); > + = cp_build_qualified_type (TREE_TYPE (type), type_quals, complain); > > if (element_type == error_mark_node) > return error_mark_node; > @@ -1431,7 +1428,7 @@ cp_build_qualified_type_real (tree type, > { > tree t = PACK_EXPANSION_PATTERN (type); > > - t = cp_build_qualified_type_real (t, type_quals, complain); > + t = cp_build_qualified_type (t, type_quals, complain); > return make_pack_expansion (t, complain); > } >