From patchwork Thu Sep 15 20:16:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp441911wrt; Thu, 15 Sep 2022 13:17:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BVQ2kPtEbCzvNPSAaokcPtFNJF7f/JryA/HZ+gOsLcsBVuGZ4zIrpu4Dhf2/1AlAWEOBQ X-Received: by 2002:a17:907:c002:b0:73d:d96c:c632 with SMTP id ss2-20020a170907c00200b0073dd96cc632mr1094843ejc.543.1663273042984; Thu, 15 Sep 2022 13:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663273042; cv=none; d=google.com; s=arc-20160816; b=Pv5LaSqzVhMPx02mDVq65uX34BCD5Yhtov4gwxZZpvWcuuwFloyyiSeKW1+dKVHvqL stwnyqRrWmiUTBNIRLsYj7zl0Oy7GXcHV5v7+azplMQo5hy7NDemI1kt5QrH1zAGNtKo +O40Gr0x+XWKLLnWe6LwPNVVMn5CGTnPX5oaWofU8xHGKQdRPbwx2Vl16f/S5xHA+XE6 gEIU8tecUP6i3BfySM1wLzsY6ZFmX91dTlgHs3UP6lHHJzWaMRmcuxQaxaGUxZ2DHxOx rsXHhVbj5VpTsuIBaegWF1y63HHySxqnek5SQBRv/CXAk6QCMKy5uTSepu8EC9fj0ZmW Du1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=WizLCyef7zHDjuWJcaBlitTrmM3RF1M34LpCcPxkbrU=; b=Lu8pALZeaEaphRhawi8F2G4vB/hNbUdleoig0B4/YUGzQdGMnGqEpF6Xeu6HAduRx3 1KdghdFIj9Gg4h2azqHgzDecVq5es3uV5OZ/EePTsFD07/FPckJcJnLm5TkSjnysyM9+ DTY78vbwnSMbYSxmvK5rGbPaNfduO5ms9/hHnJ2tZVaei5UMd6k6HFJ/lpgWuli61PHX VS0cCkP8JWud8LX09FlFsqT3GqGpex2nrEMFxzNwFD6xukqZ5ucacgA+WhzDvofdXSak +aVErEwLm7/5c0vzkNwPjopotjK+OJIS3C9tnvKpN+OmGQXoirdZg5eoLCBDjI57olSB o6xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BJD2kDT7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hr20-20020a1709073f9400b007802aafb806si6247909ejc.244.2022.09.15.13.17.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 13:17:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BJD2kDT7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B251D3839DE2 for ; Thu, 15 Sep 2022 20:17:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B251D3839DE2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663273041; bh=WizLCyef7zHDjuWJcaBlitTrmM3RF1M34LpCcPxkbrU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BJD2kDT7UEBc/Wrz6l+z/RU9bBFmdFgiyWE0g+ME4RO0B3fsE3F8Qfur7+tEVSjEj DXNBlrlQCYF43AmxHhjB1GoiBCZ03U8p3shIiymvA3TNiPbT5huK9PxxMt62kIS7vi dVSGeuB0UKKrpruTyZ8P/6Mndn3cNCPQC0pl7sMA= 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 ESMTPS id 340B5384BC2C for ; Thu, 15 Sep 2022 20:16:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 340B5384BC2C 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.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-614-JOb7ZCc2M7CsuSCsdZPcmA-1; Thu, 15 Sep 2022 16:16:36 -0400 X-MC-Unique: JOb7ZCc2M7CsuSCsdZPcmA-1 Received: by mail-qt1-f200.google.com with SMTP id g21-20020ac87d15000000b0035bb6f08778so10012719qtb.2 for ; Thu, 15 Sep 2022 13:16:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=WizLCyef7zHDjuWJcaBlitTrmM3RF1M34LpCcPxkbrU=; b=HkHcCLONyVjvGR1IExUPAT8iDcYFeeuaoDl7bzBRKN4E863vwyz6kL0sbKJQLqK1jg /YTftbFrmsHNTH3QCM6KHoW5CEwPihDo3i4IzSy5l4n9k3Rh07qT7NVnR1CGKagL5XNa lKFnGDmTysMulgfRLBT0FzVEoSKdEsLqL9X8HPiUtxviznU+ubPvzIpsK6qwLXw07Kfg Mxng+hSvB7aJlILcyW1LxZQHvprmRmIeTYCPJ6KUf0zkIGjQHR66GWzpt1mZUiYnoTIn SrKk/kpQD9EBEbq/w7wmZB1/8ZtqaWps5E0RvgSHIXVNV07sFXMp+GEsC436jvjjiG6d XAnw== X-Gm-Message-State: ACrzQf0YSX4moW0NndLhAQ0nMmWxZxfsgaISttTxkeFp0c9tvSUVgZNf mQRBay8GCT4zC6KluTfKcpxK2r2ShGvUs1kmJC0Y8Vwy+FBrLyM8VvY+9qQ3m5NfnBVx9i4ZwX+ 5v7WoCut2Wh9TN2KZZyExNvtrdRpRoMJgzCALYCTBy2THoq4XLHR7qDJ/B5jolTBkhDI= X-Received: by 2002:a05:622a:138b:b0:35b:b619:b87d with SMTP id o11-20020a05622a138b00b0035bb619b87dmr1617083qtk.146.1663272996166; Thu, 15 Sep 2022 13:16:36 -0700 (PDT) X-Received: by 2002:a05:622a:138b:b0:35b:b619:b87d with SMTP id o11-20020a05622a138b00b0035bb619b87dmr1617062qtk.146.1663272995922; Thu, 15 Sep 2022 13:16:35 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id a7-20020ac86107000000b0035ba3cae6basm4157138qtm.34.2022.09.15.13.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 13:16:35 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: modules ICE with typename friend declaration Date: Thu, 15 Sep 2022 16:16:27 -0400 Message-Id: <20220915201627.2942314-1-ppalka@redhat.com> X-Mailer: git-send-email 2.37.3.662.g36f8e7ed7d MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.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_LOW, 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.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 Cc: nathan@acm.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744068194453558817?= X-GMAIL-MSGID: =?utf-8?q?1744068194453558817?= A couple of xtreme-header-* modules tests began ICEing in C++23 mode ever since r13-2650-g5d84a4418aa962 introduced into the dependently scoped friend declaration friend /* typename */ _OuterIter::value_type; ultimately because the streaming code assumes a TYPE_P friend must be a class type, but here it's a TYPENAME_TYPE, which doesn't have a TEMPLATE_INFO or CLASSTYPE_BEFRIENDING_CLASSES. This patch tries to correct this in a minimal way. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? gcc/cp/ChangeLog: * module.cc (friend_from_decl_list): Don't consider CLASSTYPE_TEMPLATE_INFO for a TYPENAME_TYPE friend. (trees_in::read_class_def): Don't add to CLASSTYPE_BEFRIENDING_CLASSES for a TYPENAME_TYPE friend. gcc/testsuite/ChangeLog: * g++.dg/modules/typename-friend.C: New test. --- gcc/cp/module.cc | 5 +++-- gcc/testsuite/g++.dg/modules/typename-friend.C | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/typename-friend.C diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index f27f4d091e5..1a1ff5be574 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -4734,7 +4734,8 @@ friend_from_decl_list (tree frnd) if (TYPE_P (frnd)) { res = TYPE_NAME (frnd); - if (CLASSTYPE_TEMPLATE_INFO (frnd)) + if (CLASS_TYPE_P (frnd) + && CLASSTYPE_TEMPLATE_INFO (frnd)) tmpl = CLASSTYPE_TI_TEMPLATE (frnd); } else if (DECL_TEMPLATE_INFO (frnd)) @@ -12121,7 +12122,7 @@ trees_in::read_class_def (tree defn, tree maybe_template) { tree f = TREE_VALUE (friend_classes); - if (TYPE_P (f)) + if (CLASS_TYPE_P (f)) { CLASSTYPE_BEFRIENDING_CLASSES (f) = tree_cons (NULL_TREE, type, diff --git a/gcc/testsuite/g++.dg/modules/typename-friend.C b/gcc/testsuite/g++.dg/modules/typename-friend.C new file mode 100644 index 00000000000..d8faf7955c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/typename-friend.C @@ -0,0 +1,9 @@ +// { dg-additional-options "-fmodules-ts" } + +export module x; + +template +struct A { + friend typename T::type; + friend void f(A) { } +};