From patchwork Thu Aug 8 15:30:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1970591 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=GukXktaO; 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 4WfrcT13Zlz1yfV for ; Fri, 9 Aug 2024 01:31:36 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB4BC386103E for ; Thu, 8 Aug 2024 15:31:32 +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 C1F80385E459 for ; Thu, 8 Aug 2024 15:31:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1F80385E459 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 C1F80385E459 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=1723131072; cv=none; b=U4Fo7Xh1R7hSMfeE3rQzpN3jC6rVHGSfNSJuhPho5TfE+zCdfPI9S1R9q9GFUl2M+7i5RqbIG1isStQXhiGTYa+1yJOUV6ITA0xmST7RZk/5Rx/FyToegov4RvjOYp8ED6urEA+lm2coJiCpo3hVBNXfrud6d3EP72LqDH/KPS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723131072; c=relaxed/simple; bh=tUrGi9xM3000erLZPm7cpvDl99BvokmHWh8FfXGPeFk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Q6MmRtPie/zWEm8dbfOdR000qA7wsQmbjJiGrDZ+27VxGx9djr13LIhM/cyCs/Ia5UjgbZQPkPZ1UKJf8dEhcBeHmMLmllCjLzaIPtfqqHFv8Nsi+l/JZoKlRMmlRx9aNmiUlxqDU44gcLcqi/Tq9L8a/in5rPKEUHMsoJJ20uk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723131065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cVpwvQ4tuVePB3zNL+ZBJfEZgmQkExP+y7Q8ie3PsUE=; b=GukXktaOcuLeZZT85VHx4PvaBhz9caszuPTaa9jNGmoumgG7BdiYI8E1Z0g49YLZhThY7g d1mxpnna0u+vk4KLeiYyZ59khNFVMlJciDPPjpI2qOLPLahkGwY+D0Mqrzr0Z+1STtHFJn oRcBkaUTZtdyeTllpN1qNQSEL0S0RWM= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-W4neD08wMsO369guh9IcuA-1; Thu, 08 Aug 2024 11:31:03 -0400 X-MC-Unique: W4neD08wMsO369guh9IcuA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6b7a27fcd51so14252326d6.3 for ; Thu, 08 Aug 2024 08:31:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723131062; x=1723735862; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cVpwvQ4tuVePB3zNL+ZBJfEZgmQkExP+y7Q8ie3PsUE=; b=HcJi90vddetMVcZQInhGxnCJBLQ07x7iK/gGviSTrKraDUkk5D0DggLvXhubZDMsES RE7udDLIwkSyp8bE6hdpdl4M+Tpb5KOIFQv/qHUrqSaFJ7OWllD+1AqX6SX6nxp56VbO MNWxL4qXt5x7B1QuNv6FSCbU9LkW9vHUU3VE+PbMWm+naVRz+xspLLdYXB9iqbnPCI2Y fjW2nsd4Zx9YdRdHkANkZzZyf5Er2C+2RT1+5NzbgurX6mfBWqXUQL7w5fBJgpjrDCvA 88P5+NR4zdhonqMP+Kk5Trqkzjsd6fKn2GB+lSmvwLxH8WGw0jfGnm30MLiCX+K11agD DitA== X-Gm-Message-State: AOJu0Yy4zSfbCCRCaLcC0JA3rv3ljEHVwCxOA8eUrpjTSMmLN9klkxi3 xPz7v/c6FiL9H4ZqmG8Zoaawwidp6htRC8hmLu+cB0gmi72OOXgTYQGnDaJVgpThUvknvnzeEfO YkXxJG4qpoI4LlzE/Hq36JWWvBbAHiMsQ2Awa5DYnmXxzmGuOrvhR0HNmS82LcNG3WMQMTyTQbH BfY4a6+vcJs+TiTePw1LgNRMvFHN3XoyMKZNZ3 X-Received: by 2002:a05:6214:5bc3:b0:6b9:5cf1:65a3 with SMTP id 6a1803df08f44-6bd6bd805d1mr25734356d6.43.1723131062068; Thu, 08 Aug 2024 08:31:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaEhdU1fLda/MqtjzpBChgWd7yk0vUiFOiPwIsT2bfGzqRKVjeV11EfShNHwKBVexMkGHHGQ== X-Received: by 2002:a05:6214:5bc3:b0:6b9:5cf1:65a3 with SMTP id 6a1803df08f44-6bd6bd805d1mr25734006d6.43.1723131061553; Thu, 08 Aug 2024 08:31:01 -0700 (PDT) Received: from localhost.localdomain (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb9c78ae4asm68119746d6.33.2024.08.08.08.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 08:31:01 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P cleanups Date: Thu, 8 Aug 2024 11:30:54 -0400 Message-ID: <20240808153054.1949621-1-ppalka@redhat.com> X-Mailer: git-send-email 2.46.0.39.g891ee3b9db MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 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, 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 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 DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P templates can only appear as part of a template friend declaration, and in turn get partially instantiated only from tsubst_friend_function or tsubst_friend_class. So rather than having tsubst_template_decl clear the flag, let's leave it up to the tsubst friend routines to clear it so that template friend handling stays localized (note that tsubst_friend_function already was clearing it). Also the template depth comparison test within tsubst_friend_function is equivalent to DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P since such templates always have more levels than the class context, and it's not possible to directly refer to an existing template that has more levels than the current template context. gcc/cp/ChangeLog: * pt.cc (tsubst_friend_class): Simplify depth comparison test in the redeclaration code path to DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P. Clear the flag in the new template code path after partial instantiation here ... (tsubst_template_decl): ... instead of here. --- gcc/cp/pt.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 677ed7d1289..d468a3037b6 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -11764,8 +11764,7 @@ tsubst_friend_class (tree friend_tmpl, tree args) compatible with the attachment of the friend template. */ module_may_redeclare (tmpl, friend_tmpl); - if (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (friend_tmpl)) - > TMPL_ARGS_DEPTH (args)) + if (DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (friend_tmpl)) { tree parms = tsubst_template_parms (DECL_TEMPLATE_PARMS (friend_tmpl), args, tf_warning_or_error); @@ -11807,6 +11806,7 @@ tsubst_friend_class (tree friend_tmpl, tree args) CLASSTYPE_USE_TEMPLATE (TREE_TYPE (tmpl)) = 0; CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl)) = INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl))); + DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (tmpl) = false; /* Substitute into and set the constraints on the new declaration. */ if (tree ci = get_constraints (friend_tmpl)) @@ -15008,8 +15008,6 @@ tsubst_template_decl (tree t, tree args, tsubst_flags_t complain, if (PRIMARY_TEMPLATE_P (t)) DECL_PRIMARY_TEMPLATE (r) = r; - DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (r) = false; - if (!lambda_fntype && !class_p) { /* Record this non-type partial instantiation. */