From patchwork Tue May 31 17:13:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1637499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=DlGwEUgU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LCJlj6lZhz9s5V for ; Wed, 1 Jun 2022 03:13:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11CDF384B07B for ; Tue, 31 May 2022 17:13:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11CDF384B07B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1654017232; bh=4niKjzGWgsvLDfTuoPAPeYmGeI1U3H9TI/H6Pvo5Gn4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DlGwEUgUzeGz5YBZXqLd8AwYlN8DUkqmsHbklLV4ADXt3awnmT9F2kpp4So+m8TaJ 2JoSHiMIlQjwGlW5TJQ7/G9SGR6RORyiKQgPQgfRSdTFXEOwD1FvqNI4NmcH2K+YG2 o8v2jpRYowI2c35NBOl3BDiCyqy2rJAYHnveap6k= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 636D5395C00F for ; Tue, 31 May 2022 17:13:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 636D5395C00F Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-Qg3PUtN9NZ2Ee0RKEDI7nQ-1; Tue, 31 May 2022 13:13:11 -0400 X-MC-Unique: Qg3PUtN9NZ2Ee0RKEDI7nQ-1 Received: by mail-qt1-f197.google.com with SMTP id c16-20020a05622a059000b002f93304d0d8so12728308qtb.14 for ; Tue, 31 May 2022 10:13:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4niKjzGWgsvLDfTuoPAPeYmGeI1U3H9TI/H6Pvo5Gn4=; b=ILgf3X6nuj+RsGDlgBJmEczMoMT8oEPzFjXGHOyd0Vr+LYJFLQZfKN07I7Xr6ukcWj qmYBpihjY9KrTCuon9uUe9QBGeiA+wEtTZ+BXWz4a/WkYwyl5XQ/OzNCmLrUYUPzmJxe wTgqSbYxyxbhNB3fUhbnSvojf2hfubmS0dkUzHuTRE6Fk8UgXufkG+hvwItwdrbB2QSb R1TPtIANNAfArWoz04S9PvHEKbWz+SAr3LxDJmfe2zln0Eq/BLylm0to0ZjCBH457CoV p1C3xeCAqLzbyd0LeyVy1l+Ur0Mnbq5xEHQmFb9wk60qHMdp5ouDMyvOlNVq7iJ9z4z0 fHMQ== X-Gm-Message-State: AOAM533LETEvY5JdqCKn9OI3U6jiv0A140Y0qRqm0l748UF7IsJkOLTc Ivc4lrizMBHK92pa+dWZxZko613Z8BbohR4eDvRFT3nGRag/fBbk0u8MxQ24SOkFL12qwlGVa91 CjIRHlA29NYg9Wgh150x/y8UzIqpKg598VqSHzQCy29ztVLifHT1GbQM07x1SvOUpYE4= X-Received: by 2002:a05:622a:11:b0:2f3:ba6b:7139 with SMTP id x17-20020a05622a001100b002f3ba6b7139mr49260524qtw.411.1654017190979; Tue, 31 May 2022 10:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEVuNx0+TA6QaOOdyt7c2k9xVnIfkq+84MqrupMaEUfnGNZLMFs6nHkc3wzlnGsX+eM9lAaA== X-Received: by 2002:a05:622a:11:b0:2f3:ba6b:7139 with SMTP id x17-20020a05622a001100b002f3ba6b7139mr49260502qtw.411.1654017190629; Tue, 31 May 2022 10:13:10 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id d13-20020a05622a15cd00b002fb673aa50asm9507151qty.89.2022.05.31.10.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 10:13:10 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: squash cp_build_qualified_type/_real Date: Tue, 31 May 2022 13:13:08 -0400 Message-Id: <20220531171308.131365-1-ppalka@redhat.com> X-Mailer: git-send-email 2.36.1.203.g1bcf4f6271 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.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_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-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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? 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); }