From patchwork Fri Apr 12 00:40:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1922797 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=kspUy2q6; 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 4VFyQl2l0vz1yYP for ; Fri, 12 Apr 2024 10:40:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7523E3858D38 for ; Fri, 12 Apr 2024 00:40:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 404533858D33 for ; Fri, 12 Apr 2024 00:40:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 404533858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 404533858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712882410; cv=none; b=qNcKuAFYlo8U0vLkh0OMHr7Dn7PC86+kesxwfTmdta0CkQJHYOVxS0SQnnFKDtaO0qf0Vp2P8GT2MPla41/hnlh22ocJg91UmQttey1chugybLCqj0Tju4S8LBhf1OT7by6CSFZLZsLlKRQV7KtxPe873lUBRq6Nxkl7DbArDXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712882410; c=relaxed/simple; bh=ddKsAunu48LEkkNpusGIjJ8dnZQDpdtQkAvbBAgCgN0=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=mgj1WOv8M5cbYRIzcRMmPQltCe/c1Ry8oTQ2Qi6B6eUhRYzCz8MnEbM3VFLySKz8T41+anazBfMfAnR2JQmQfVqwIi+3+/tA1JZ3/pf/pq+ZIM17v55OwO1s0xnh0iyJZfv853m/Rg4bg6xNx87wSBtN2l4+Y/CFE+hCYWFAe1Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1e45b9a5c53so3267595ad.3 for ; Thu, 11 Apr 2024 17:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712882407; x=1713487207; darn=gcc.gnu.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=8PWjCpKcx2okGY5Jp+pdunvu6LbT5KlTG7RXaGeQEyw=; b=kspUy2q6fTXV4XOFEgMEX8NkFEMjhJCFvXK2+RtjaG3Rn3/0ZzThOXfZzP/E8FQFTP U5UdPPHp97X6qvwwuM8eq0zrwg4cuJjmD1E6+r+P8TnPMpN5lXAcljKG+mGunX6uiIzT 4y012qvqEGOSgeb5UwgU1mhOYypzE+P6ee4C5OFivwkWi87V53c0yXcrN/7hVWbl4BQC 60vWuUe9oGtTuyAM4caaEwwPZbYNMI5pAD9lbNDlfgcxo0L+Vni8TcW79tPxVt1D0/Ru TzlLBPdMhhyTlmNpqI+BZizcQUlWR383TZi8Hvnn0lJ5wYfA6W+goNQnWX4v9H2Ll75y Pt/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712882407; x=1713487207; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8PWjCpKcx2okGY5Jp+pdunvu6LbT5KlTG7RXaGeQEyw=; b=MYp4XIuWu7dO4apS+JRYWQrkHzwYufPquutYZJCAOdDch/33IXa7En2uFArt9zseV4 xaeyIBRoF/v6LlUwmNMyRjNTN7vFHLzFL4Am4GKKi/WW6X08JkGGakc62fglu1ht6YFF iPm6MRIDjlDrQ+BMUb2H8tBVghQX/fzZI2oK+znONP1s7zgMAuZxbljTFNqvDs7A9j7H IlBh3qgSeYpPVryiyAY/GEDz+N9Z+aiT09V/LvJwCHNNuHt2Cv7/hbevmiuj2d7kY9SR UPInCId2qznM/6lsUQB0KIA+UMrfczH2KsUhqlN+WOWK/RLQZIVSQ87nAXFN/4dkhcHV 6eUw== X-Gm-Message-State: AOJu0Yzk3vDb0SNctTTSGyJfMxvpNy0D9+npeIQuBQx/2hX5qiYH5odG 7CV7Invua+gF24SpRFJycd7Qf6gnuxEFh79xDVzBBBWGVIg7emCiyZaTMg== X-Google-Smtp-Source: AGHT+IE65FLWQU7crOQECFh2g/O8k0eTngtkLP4zxnDvscmspeRLM9XnKu65SO+GOEn1XlvmrVbHZg== X-Received: by 2002:a17:903:1c9:b0:1e4:55d8:e5f1 with SMTP id e9-20020a17090301c900b001e455d8e5f1mr1174149plh.5.1712882407143; Thu, 11 Apr 2024 17:40:07 -0700 (PDT) Received: from Thaum. (121-44-11-123.tpgi.com.au. [121.44.11.123]) by smtp.gmail.com with ESMTPSA id e13-20020a170902784d00b001defa97c6basm1806771pln.235.2024.04.11.17.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 17:40:06 -0700 (PDT) Message-ID: <661882e6.170a0220.5eebf.5da0@mx.google.com> X-Google-Original-Message-ID: Date: Fri, 12 Apr 2024 10:40:02 +1000 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell , Patrick Palka Subject: [PATCH 1/3] c++/modules: Only emit exported GMF usings [PR114600] References: <66188279.170a0220.e9635.a08c@mx.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <66188279.170a0220.e9635.a08c@mx.google.com> X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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 Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- A typo in r14-6978 made us emit too many things. This ensures that we don't emit using-declarations from the GMF that we don't need to. PR c++/114600 gcc/cp/ChangeLog: * module.cc (depset::hash::add_binding_entity): Require both WMB_Using and WMB_Export for GMF entities. gcc/testsuite/ChangeLog: * g++.dg/modules/using-14.C: New test. Signed-off-by: Nathaniel Shead Co-authored-by: Patrick Palka --- gcc/cp/module.cc | 2 +- gcc/testsuite/g++.dg/modules/using-14.C | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/modules/using-14.C diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 4e91fa6e052..9d054c4c792 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -12892,7 +12892,7 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) inner = DECL_TEMPLATE_RESULT (inner); if ((!DECL_LANG_SPECIFIC (inner) || !DECL_MODULE_PURVIEW_P (inner)) - && !(flags & (WMB_Using | WMB_Export))) + && !((flags & WMB_Using) && (flags & WMB_Export))) /* Ignore global module fragment entities unless explicitly exported with a using declaration. */ return false; diff --git a/gcc/testsuite/g++.dg/modules/using-14.C b/gcc/testsuite/g++.dg/modules/using-14.C new file mode 100644 index 00000000000..0e15a952de5 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-14.C @@ -0,0 +1,14 @@ +// PR c++/114600 +// { dg-additional-options "-fmodules-ts -Wno-global-module -fdump-lang-module" } +// { dg-module-cmi M } + +module; +namespace std { + template struct A { int n; }; + template A f(); + namespace __swappable_details { using std::f; } +} +export module M; + +// The whole GMF should be discarded here +// { dg-final { scan-lang-dump "Wrote 0 clusters" module } } From patchwork Fri Apr 12 00:40:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1922798 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GS4Y3hYH; 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 4VFyRN4n6xz1yYP for ; Fri, 12 Apr 2024 10:41:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4A28385840C for ; Fri, 12 Apr 2024 00:41:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 0AE68385842A for ; Fri, 12 Apr 2024 00:40:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0AE68385842A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0AE68385842A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712882439; cv=none; b=YPla+ntQyy/yufm6cXNFgyrw2DjF6Tc9sCfpv+vtvOsR4j9BlrPsYu8VAgaclnse0RM2y6Jd8uUbd9y56NiAVUf6WJtlFiWGfNI2t1mu0et8Dz6bu/KnBJo9a58E82ZB9P/y3fgoFmf/YBjPKGW+khf/dJVF6O+7/MihUIhKiD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712882439; c=relaxed/simple; bh=HkbrYwTTM5x07hp3takwZvGWGtdiGyrUnGm5GmXqYGk=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=lVXio46zA7ZTRJHCcIBpz0lzRC1IwrPS8rVtlHkUM0J4ZpALqh7P/mRDDmLMfogMF7Je+aL1X1mzxdgvtDfy0q0zFjjIVMYERfovccj7xducMtj/WAouKJYcOj14vskLgeMYOavt7aLZMLM3rfxIqe40Fe06pT1y59CxU6HWv7I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e3cf5b171eso3787565ad.0 for ; Thu, 11 Apr 2024 17:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712882436; x=1713487236; darn=gcc.gnu.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=2B/3n85ZfK8F5oGmL+kDW+6zjePtdE126nxvzd9DtqM=; b=GS4Y3hYH2jLKuWHxot2qU4Li8S7XSixPWlfOTEhrRnggjIzLZiPmu0U1+Kxb7jJtES elaNi4o7/SpF8l2KDenpogwoRc1ioDwmRmKc2M7ZETtkvaX2nxpLvlepqDK5yAURdQOO 2WuEQqdASsrMTTl58fewFZdO1NihniumalAVvm3qaoF5Le3HMJodNpSbpFdCB6Qi2fQB wYf40n+dQcSXgpbti5h4KHAAFsvU0Un7WG1Ifu9ertTg9T4lfX5oBFWQcZ7sUYkWxRsc XQ2IFzWv94PsIvlofzp8jKtkE1MS63aGV/nF0T674gsIqkgUD8JSr5XmjpaAAgHcKtjY QI2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712882436; x=1713487236; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2B/3n85ZfK8F5oGmL+kDW+6zjePtdE126nxvzd9DtqM=; b=aABH0BivyevpYb/JmY3C5+y/Q+SFmc7ajcSwQUQ99A7vfK7bQG+aLhD8w7pQuABi/5 DdR/kVWv7b80yKFP2ywy9UtGcLIfsSwT3ZlD/cijygTus8UavzNS2R7+CKzqW98qY38q 7SaB7TWZmSxM/jw7YsvMZ0iPRPKNFx7mYqthNaDpDqb8MZ/mggKRA1W9vE4j1wBeTsmk qWWVer62Ukb4ughHerv8vo0fyHBWObCCA9NYn1jaNMIvXU5vdk+9TcJCuSwwE9auHlBO SPdL9aTJMMJxoZM1x3m8ciBJhegaAZttmhf/T0BtTQwP2c89weLiBcM/Wb8WMo7X4gSK lS3g== X-Gm-Message-State: AOJu0YzICPbwTfzvnZwtnFB4pB06GVHdKM1cM2xfmNOqoLtWtAuFrTUx 7dgs7e85sSpydLtmebawzy3/GGthYut9a8cMKi91IIJikAua8dgpD0dWQw== X-Google-Smtp-Source: AGHT+IEkJCUZJs0THUpYbmHFHiBXyZON1eMixaEvUtFly3E5cnXo1Sl0lJBr7Z1ArZca+wg1eEqfcg== X-Received: by 2002:a17:903:2b0c:b0:1e4:9ad5:752d with SMTP id mc12-20020a1709032b0c00b001e49ad5752dmr1371958plb.57.1712882435879; Thu, 11 Apr 2024 17:40:35 -0700 (PDT) Received: from Thaum. (121-44-11-123.tpgi.com.au. [121.44.11.123]) by smtp.gmail.com with ESMTPSA id t9-20020a170902e84900b001dd6f1516a0sm1779079plg.87.2024.04.11.17.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 17:40:35 -0700 (PDT) Message-ID: <66188303.170a0220.8de00.5a7c@mx.google.com> X-Google-Original-Message-ID: Date: Fri, 12 Apr 2024 10:40:31 +1000 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell , Patrick Palka Subject: [PATCH 2/3] c++/modules: Propagate using decls from partitions References: <66188279.170a0220.e9635.a08c@mx.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <66188279.170a0220.e9635.a08c@mx.google.com> X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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 Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- The modules code currently neglects to set OVL_USING_P on the dependency created for a using-decl, which causes it not to remember that the OVL_EXPORT_P flag had been set on it when emitted from the primary interface unit. This patch ensures that it occurs. gcc/cp/ChangeLog: * module.cc (depset::hash::add_binding_entity): Propagate OVL_USING_P for using-declarations. gcc/testsuite/ChangeLog: * g++.dg/modules/using-15_a.C: New test. * g++.dg/modules/using-15_b.C: New test. * g++.dg/modules/using-15_c.C: New test. Signed-off-by: Nathaniel Shead --- gcc/cp/module.cc | 4 ++++ gcc/testsuite/g++.dg/modules/using-15_a.C | 13 +++++++++++++ gcc/testsuite/g++.dg/modules/using-15_b.C | 5 +++++ gcc/testsuite/g++.dg/modules/using-15_c.C | 7 +++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/modules/using-15_a.C create mode 100644 gcc/testsuite/g++.dg/modules/using-15_b.C create mode 100644 gcc/testsuite/g++.dg/modules/using-15_c.C diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 9d054c4c792..527c9046c67 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -12915,10 +12915,12 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) /* Ignore NTTP objects. */ return false; + bool unscoped_enum_const_p = false; if (!(flags & WMB_Using) && CP_DECL_CONTEXT (decl) != data->ns) { /* A using that lost its wrapper or an unscoped enum constant. */ + unscoped_enum_const_p = (TREE_CODE (decl) == CONST_DECL); flags = WMB_Flags (flags | WMB_Using); if (DECL_MODULE_EXPORT_P (TREE_CODE (decl) == CONST_DECL ? TYPE_NAME (TREE_TYPE (decl)) @@ -12979,6 +12981,8 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) if (flags & WMB_Using) { decl = ovl_make (decl, NULL_TREE); + if (!unscoped_enum_const_p) + OVL_USING_P (decl) = true; if (flags & WMB_Export) OVL_EXPORT_P (decl) = true; } diff --git a/gcc/testsuite/g++.dg/modules/using-15_a.C b/gcc/testsuite/g++.dg/modules/using-15_a.C new file mode 100644 index 00000000000..23895bd8c4a --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_a.C @@ -0,0 +1,13 @@ +// { dg-additional-options "-fmodules-ts -Wno-global-module" } +// { dg-module-cmi M:a } + +module; +namespace foo { + void a(); +}; +export module M:a; + +namespace bar { + // propagate usings from partitions + export using foo::a; +}; diff --git a/gcc/testsuite/g++.dg/modules/using-15_b.C b/gcc/testsuite/g++.dg/modules/using-15_b.C new file mode 100644 index 00000000000..a88f86af61f --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_b.C @@ -0,0 +1,5 @@ +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi M } + +export module M; +export import :a; diff --git a/gcc/testsuite/g++.dg/modules/using-15_c.C b/gcc/testsuite/g++.dg/modules/using-15_c.C new file mode 100644 index 00000000000..0651efffc91 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_c.C @@ -0,0 +1,7 @@ +// { dg-additional-options "-fmodules-ts" } +import M; + +int main() { + bar::a(); + foo::a(); // { dg-error "not been declared" } +} From patchwork Fri Apr 12 00:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1922799 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=nI8FnGLC; 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 4VFySB4vm9z1yYP for ; Fri, 12 Apr 2024 10:41:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5E9D3858294 for ; Fri, 12 Apr 2024 00:41:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 86B60385843B for ; Fri, 12 Apr 2024 00:41:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86B60385843B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 86B60385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712882478; cv=none; b=w+xaUPu/wF2dc6wY21D76UMQ4SGtzsiv9LMZoEDp9iAsEd174mMRLAswEO9+nIuxlryFCt8GTfB9yiS/BZkvdlsySooEbohBSWwBx55CJz8AVpnN7cpJoQtVpzTxvg8Jl4pVK4SUnHHG+NuUonRzd/85bAeuZLsyjGayA+PuAJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712882478; c=relaxed/simple; bh=R5bqAs4WwzlYywX4FjLn2YHtqNBOd9IBqiTia9Y+hIk=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=En9DivYk1ajd0NtB7NtlAfSsdVd/fn+Hy2OMRq8QbBj/EfIfxegw41af5QnhUnlgwSvPo0g3rTmMx9Lm52dFJapxnolN5Q8L/SMCHFGq8cAZriozK2eIGYCJ0J6NFDf4wi7Mms3+xvG3lCaONiTo/WmDnEqnDkZDqjYwPhUYv8A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6ea1ef9e4e9so202021a34.1 for ; Thu, 11 Apr 2024 17:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712882476; x=1713487276; darn=gcc.gnu.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=JWjcQbkNRYRWQgCDM3C4/9l7REFHsLbGCFbqzIZyBoM=; b=nI8FnGLCiF44DvGdboiKcsVPHTfMn/ByP5LwjfgRp53uS37yq+oWYiEF5Rc9B4faYu xuYrbseieIRtTiOTCEbDWuMScTYmH4pK3QGKdVh2J7bo6nLmhH7FhmYjO/+slWgF3Cv6 vYX960DeeMi3bQWbc4Ent9GhcxSmE4mbSbY5/oszMtsviqrrkzoc18wA+1CDSJbpsx16 Mn+rPdkkS8c8BCfCnozLcMmNkEW1i0iaKNr6LXuu5v8269IqiSOfhh/kPCHvVQRgFnjA r0AJvCNvvdSgtv5xbiCYowIxAM99LnCa3dH7u8sAwwcsE4NDGU5gLctUR/pwSR1DOACv C2DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712882476; x=1713487276; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JWjcQbkNRYRWQgCDM3C4/9l7REFHsLbGCFbqzIZyBoM=; b=CAu2rnpV+7Np4+lXQMGtSMgV4OG25B1z5jXJqNRisDsOe1q8LRIW4vM18x1klY2v2C m8qqKshz6dGygLwSAn7GXOPw/sdKhBIoZ69Nz3hMsI4F6jWUrrPTGiLACGTy97QnRBr8 Gep2hTnNsfs1Kka974EDv3a1d6fTesUIUmfPdYQPJ9ZBzHpHeGDrbUQNg5cFnt7MScPg dmKYJmiNyxOp2osCagPp/6SBbLC9HHhuOJWBq5n1NwUpUX3/teYH9PFNckkC8d7IxfGe aVIIpZAv7SqmgTqdnWdVViGzyBDuvadIozmNdFsJRC9EupAd7VRc7QlVKTwoCURwwwbz M2KA== X-Gm-Message-State: AOJu0YwY8hbDfh+d0s4aVEIF8ZfNwD8U5GgaQCIuivGx5+aUZr6M3EE3 2RYSMcmCgV33GAAAxwu8C2cm+EuhxWiLR3wNEW0kAdHCgrEh8n/n85Sqtg== X-Google-Smtp-Source: AGHT+IFDGzfOjyc48NjTmPiSxoMYnxSZYHDf7Wv1qti5+i6OY4eod5fCGXbkBxbNnZznAXruhvnNJw== X-Received: by 2002:a9d:7e9a:0:b0:6ea:32c7:97e2 with SMTP id m26-20020a9d7e9a000000b006ea32c797e2mr1419679otp.7.1712882475739; Thu, 11 Apr 2024 17:41:15 -0700 (PDT) Received: from Thaum. (121-44-11-123.tpgi.com.au. [121.44.11.123]) by smtp.gmail.com with ESMTPSA id n184-20020a6327c1000000b005df41b00ee9sm1669655pgn.68.2024.04.11.17.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 17:41:15 -0700 (PDT) Message-ID: <6618832b.630a0220.8e0f.544a@mx.google.com> X-Google-Original-Message-ID: Date: Fri, 12 Apr 2024 10:41:10 +1000 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell , Patrick Palka Subject: [PATCH 3/3] c++/modules: Propagate hidden flag on decls from partitions References: <66188279.170a0220.e9635.a08c@mx.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <66188279.170a0220.e9635.a08c@mx.google.com> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- While working on some other fixes I noticed that the partition handling code used the wrong flag to propagate OVL_HIDDEN_P on exported bindings from partitions. This patch fixes that, and renames the flag to be clearer. gcc/cp/ChangeLog: * name-lookup.cc (walk_module_binding): Use the partition-specific hidden flag instead of the top-level decl_hidden. gcc/testsuite/ChangeLog: * g++.dg/modules/using-16_a.C: New test. * g++.dg/modules/using-16_b.C: New test. * g++.dg/modules/using-16_c.C: New test. Signed-off-by: Nathaniel Shead --- gcc/cp/name-lookup.cc | 10 +++++----- gcc/testsuite/g++.dg/modules/using-16_a.C | 11 +++++++++++ gcc/testsuite/g++.dg/modules/using-16_b.C | 12 ++++++++++++ gcc/testsuite/g++.dg/modules/using-16_c.C | 11 +++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/using-16_a.C create mode 100644 gcc/testsuite/g++.dg/modules/using-16_b.C create mode 100644 gcc/testsuite/g++.dg/modules/using-16_c.C diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 7af7f00e34c..b7746938e1b 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -4274,19 +4274,19 @@ walk_module_binding (tree binding, bitmap partitions, count += callback (btype, flags, data); } - bool hidden = STAT_DECL_HIDDEN_P (bind); + bool part_hidden = STAT_DECL_HIDDEN_P (bind); for (ovl_iterator iter (MAYBE_STAT_DECL (STAT_DECL (bind))); iter; ++iter) { if (iter.hidden_p ()) - hidden = true; + part_hidden = true; gcc_checking_assert - (!(hidden && DECL_IS_UNDECLARED_BUILTIN (*iter))); + (!(part_hidden && DECL_IS_UNDECLARED_BUILTIN (*iter))); WMB_Flags flags = WMB_None; if (maybe_dups) flags = WMB_Flags (flags | WMB_Dups); - if (decl_hidden) + if (part_hidden) flags = WMB_Flags (flags | WMB_Hidden); if (iter.using_p ()) { @@ -4295,7 +4295,7 @@ walk_module_binding (tree binding, bitmap partitions, flags = WMB_Flags (flags | WMB_Export); } count += callback (*iter, flags, data); - hidden = false; + part_hidden = false; } } } diff --git a/gcc/testsuite/g++.dg/modules/using-16_a.C b/gcc/testsuite/g++.dg/modules/using-16_a.C new file mode 100644 index 00000000000..25d8bca5d1c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-16_a.C @@ -0,0 +1,11 @@ +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi M:S } + +export module M:S; + +namespace foo { + // propagate hidden from partitions + export struct S { + friend void f(S); + }; +}; diff --git a/gcc/testsuite/g++.dg/modules/using-16_b.C b/gcc/testsuite/g++.dg/modules/using-16_b.C new file mode 100644 index 00000000000..3f704a913f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-16_b.C @@ -0,0 +1,12 @@ +// { dg-additional-options "-fmodules-ts -Wno-global-module" } +// { dg-module-cmi M } + +module; +namespace bar { + void f(int); +} +export module M; +export import :S; +namespace foo { + export using bar::f; +} diff --git a/gcc/testsuite/g++.dg/modules/using-16_c.C b/gcc/testsuite/g++.dg/modules/using-16_c.C new file mode 100644 index 00000000000..5e46cd16013 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-16_c.C @@ -0,0 +1,11 @@ +// { dg-additional-options "-fmodules-ts" } +import M; + +int main() { + // this should be hidden and fail + foo::f(foo::S{}); // { dg-error "cannot convert" } + + // but these should be legal + foo::f(10); + f(foo::S{}); +}