From patchwork Wed Sep 4 17:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1980967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fbPLEBik; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzVP91x75z1yXY for ; Thu, 5 Sep 2024 03:49:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D29D23861825 for ; Wed, 4 Sep 2024 17:49:29 +0000 (GMT) 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 ESMTP id 8A9C6385EC1E for ; Wed, 4 Sep 2024 17:49:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A9C6385EC1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8A9C6385EC1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725472145; cv=none; b=iPTLGT6hGDJoSHyzAi/xuHqjZ7kePsxklExv0QiacJbJaDTNH7H/rX9JS3lICLztTJ2ygH+1mj1q/m2UJfn7/hJxBDlpVsYeZ4oRp/PNVodJMxUYj7PYIts8vrCFD9WBN7yEto/0ajw2Ob/p6WSZFOMAo//BkXiUbki59We37p0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725472145; c=relaxed/simple; bh=xk1UJZGM1PzhnjpT8vWV8rMhxvDNw9sDbIrZdWYgF6M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ew4sMIDI1OG7BCmGYNGhyJQR6IzYOZUCNxPcHiPq0lx5eDti9iA4btZdrScuwfeFyMpWZadJXfC282bdB2o+GjjqbN6kOn+YyaXlpT9EcMA2jLgMMY7tge/Rmk5jwFbhKvv2lLVXwDR0bBrVb99WLnJTzlnWUldMoAZjQCjGokU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725472142; 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; bh=LEceDNMpVmIFzHGvm5c3pUzvTTslBG1NsP7tAcJUPqk=; b=fbPLEBikYsPWUmR1710RM8id5xD0FNzdSWfQebuZtB8c3FNF2C+y6BZePW8J0dh4yV3jT0 t1rH8t4yF7tbSkG997ojjiTcbjyNdsS9yCZihEN9njY0zGOxJz7wCgis3REObW/a/zQCNF zSJMjdJrCwbaSC59HHAosoN8uebXK1k= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-30-5AMkrv1-Oxme4kIrEdtsbw-1; Wed, 04 Sep 2024 13:49:00 -0400 X-MC-Unique: 5AMkrv1-Oxme4kIrEdtsbw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C94781953945 for ; Wed, 4 Sep 2024 17:48:59 +0000 (UTC) Received: from pdp-11.lan (unknown [10.22.33.19]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3942A1956086; Wed, 4 Sep 2024 17:48:58 +0000 (UTC) From: Marek Polacek To: GCC Patches , Jason Merrill Subject: [pushed] c++: cleanup coerce_template_template_parm Date: Wed, 4 Sep 2024 13:48:56 -0400 Message-ID: <20240904174856.467697-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Split out from https://gcc.gnu.org/pipermail/gcc-patches/2024-September/662261.html which was tested on x86_64-pc-linux-gnu. I'm checking this in. -- >8 -- This function could use some sprucing up. gcc/cp/ChangeLog: * pt.cc (coerce_template_template_parm): Return bool instead of int. --- gcc/cp/pt.cc | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) base-commit: c755c7a32590e2eef5a8b062b9756c1513910246 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 747e627f547..1225c668e87 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -7887,25 +7887,22 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) return convert_from_reference (expr); } -/* Subroutine of coerce_template_template_parms, which returns 1 if - PARM_PARM and ARG_PARM match using the rule for the template - parameters of template template parameters. Both PARM and ARG are - template parameters; the rest of the arguments are the same as for - coerce_template_template_parms. - */ -static int -coerce_template_template_parm (tree parm, - tree arg, - tsubst_flags_t complain, - tree in_decl, - tree outer_args) +/* Subroutine of coerce_template_template_parms, which returns true if + PARM and ARG match using the rule for the template parameters of + template template parameters. Both PARM and ARG are template parameters; + the rest of the arguments are the same as for + coerce_template_template_parms. */ + +static bool +coerce_template_template_parm (tree parm, tree arg, tsubst_flags_t complain, + tree in_decl, tree outer_args) { if (arg == NULL_TREE || error_operand_p (arg) || parm == NULL_TREE || error_operand_p (parm)) - return 0; + return false; if (TREE_CODE (arg) != TREE_CODE (parm)) - return 0; + return false; switch (TREE_CODE (parm)) { @@ -7916,7 +7913,7 @@ coerce_template_template_parm (tree parm, { if (!coerce_template_template_parms (parm, arg, complain, in_decl, outer_args)) - return 0; + return false; } /* Fall through. */ @@ -7924,7 +7921,7 @@ coerce_template_template_parm (tree parm, if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (arg)) && !TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (parm))) /* Argument is a parameter pack but parameter is not. */ - return 0; + return false; break; case PARM_DECL: @@ -7940,13 +7937,13 @@ coerce_template_template_parm (tree parm, tree t = tsubst (TREE_TYPE (parm), outer_args, complain, in_decl); if (!uses_template_parms (t) && !same_type_p (t, TREE_TYPE (arg))) - return 0; + return false; } if (TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (arg)) && !TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (parm))) /* Argument is a parameter pack but parameter is not. */ - return 0; + return false; break; @@ -7954,7 +7951,7 @@ coerce_template_template_parm (tree parm, gcc_unreachable (); } - return 1; + return true; } /* Coerce template argument list ARGLIST for use with template