From patchwork Wed Jan 3 10:01:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 184689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4926258dyb; Wed, 3 Jan 2024 02:02:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IE72JaTdmNrXtRgexWPEluFBsiZ0y/qXIKowiLC3UdiziDqrKJmc+Rucg23gCA9UMu0evST X-Received: by 2002:a05:622a:386:b0:425:aa85:e016 with SMTP id j6-20020a05622a038600b00425aa85e016mr24007290qtx.42.1704276153470; Wed, 03 Jan 2024 02:02:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704276153; cv=pass; d=google.com; s=arc-20160816; b=pw2SY4SBWLoBhsS2LcfEEeGG3wTdNK4hEwSXQnBMQlDCxasKHiPN6TotfNzedntU63 xvchx7PV3W/EpyihZL+FbZpegJwX+yeNEK8w1KEuQiIVLvfzUi/YPer5POFnEfMpxogq +wgJ2q8PGTPdPmDwWWajmFuJUTPMces5v4IPJCDbGqLnq2I8Gw3i0NkvU10mfLltkNJ+ nO0o329j9yJiFoTgNu3KbdCyeITlDcdUfbGqaoaCQDo/ea1Fq6PTTPgnL8uhoTjdiYGy 3afJ/CeoO7pFun5S8zTPWcymfKnzr/sVVOCmoenXk9Onj6Nh23D7iw4qmjzyRq+C8789 TMpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:subject:cc:to:from:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ojiR9URTpZCy6TBQmc07WXh5d5xdi9aijFt0SoSIFr8=; fh=PSfnKtImOwcFiHTY31kD+1EEfyCGdToyJVXnD0Outng=; b=lHJ6g8fd/cr8RoM7HPjI9fj/oBu63c8NPlzHHQKBMdkQGj1fULIQY53KD7ZA9W6cpW jY7AnOtJ5BbkAGDMICOQ+dxK4of069EAa/k0wfHTEAmYGUx12ibcs4YjSXeUU+6ACjg9 2uR+Uo/Czl2p5FpvzMcBeTB/kxe0YAcvGv1c32mAxe8SBl8iGYeE0+5nx1DCJ5NVp3L1 gQn1rAvJq6GfYGG8nfo8CmFLMAtyVIhXHGtcaEdNKYQF2kzS9NlZ/9/sf6lf7x5GBndS 2rGdCzXWis/BfzIf3ORTuGXtP5xzN9+u3L17N08CjJEL40JgBHn50qzHPqNjV1UoP8XC Ek/Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Lj/BJFyL"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f40-20020a05622a1a2800b0042839f5ebc5si420859qtb.694.2024.01.03.02.02.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 02:02:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Lj/BJFyL"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B0BD3858038 for ; Wed, 3 Jan 2024 10:02:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id EE9EC3858C2C for ; Wed, 3 Jan 2024 10:01:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE9EC3858C2C 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 EE9EC3858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704276108; cv=none; b=ukLGoyD/gOUJCfzvc21inWnEoiEJFVcnkgkWGe0NzpIa5uw50C4TZskIgvLpuvR31lUXNojFyTJah2XgPDTa3gdf7i79+o5d00Sl4YJH37VVa7gYsqFmiyP5uw9B8PAeanlBLV77HtLLQAUsULNNt7utdUOwYUoNDjK6vfhyf+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704276108; c=relaxed/simple; bh=PuSuQ68aDFw9EI/PJ3VLIlMa/vJqCXa8SOuFox1GOz8=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=ZWHYoAnYtkUUKB/J2i2Ka1qL4/OToGVIlL6J/LWX/um53a2PfQIpig+D8ZCImkoAEXwWuy04jAWon47R0hVtzWsZWbiLX/HnnzAeZH6hVo8EflKTsx1RZZk7iDekxd2TM28VCO88MzmIYLWXN8VpUNCvcH4mcXM6MMSlKbKmd6Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6dc36e501e1so2869835a34.1 for ; Wed, 03 Jan 2024 02:01:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704276105; x=1704880905; darn=gcc.gnu.org; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ojiR9URTpZCy6TBQmc07WXh5d5xdi9aijFt0SoSIFr8=; b=Lj/BJFyLzSuSaXwfbY2IooCzUH9mkp0I8BbKJK0b9EppiOFS+LTsdT6OBwkz4GQWo+ 8p0vQ/toSRwPm436aQ/Mfo/R4V0pBZXnqtBDHvzpWt9gjWgNXLKV9+LTzFlTle4Rpt54 WrcO9DdeCQXUquI9CfsPd5S8TVUddpFPSi0lzHKHVLJTvy32zOodHlqrYrTosWBSALVA 91aRX+RVytaqsWtY9eXAsRIjiHbl3VH9Juxa68s2jhmgD9q7pBZlkWik9EMNJoEayLXT emjU34lguBEiZQ3vO0XQxBI79OD1CyRXlfCE9u4vYrCj7w7K9/563ElMfK8Em3JIVdLp xOyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704276105; x=1704880905; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ojiR9URTpZCy6TBQmc07WXh5d5xdi9aijFt0SoSIFr8=; b=oNLkJ0iDuICN4IEFSUwn45hD3cGnuVDApc+GRUGmpyRazvnrN8HV5J7o6qEQZ5CkQT xVHguzXkbraBI+6iIvcxcGCMIzApg9aGs8ZfaNGZUF7jYR4PHl9rnMdVtU2MkdAZpA3J kVJBXFholJKNuOcss+nYMqKoEZTh65Vm8e9LorYY96Ot+5Cm3oLfqL7AyOXGwgyI+e2H F2+dwDsrzBwDCjux4Xde9SRczoJ0YympsfRGM331aX2b9WA1o8XRXuOpTKnzd/clW5Q0 ifH+ipAqJxRePldQaT7ZvebhLb9E/68U35JuLsLZ17fTEsraH7SVEU3Yq0jlXaFrGIj6 RSKg== X-Gm-Message-State: AOJu0Yy9ZKpN8FBKpdjKXfw2vmXO2VxBsgISs0sYf3Hbui6HbE6QKeXj WnrW/PVdeZ7AbH3JLDzot/OLh5fW/0Y= X-Received: by 2002:a05:6358:50c6:b0:175:56b0:8341 with SMTP id m6-20020a05635850c600b0017556b08341mr1028938rwm.7.1704276104597; Wed, 03 Jan 2024 02:01:44 -0800 (PST) Received: from Thaum. ([203.166.236.30]) by smtp.gmail.com with ESMTPSA id v22-20020a056a00149600b006d9b65d1a8esm16760920pfu.28.2024.01.03.02.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 02:01:44 -0800 (PST) Message-ID: <65953088.050a0220.d187.0c52@mx.google.com> X-Google-Original-Message-ID: Date: Wed, 3 Jan 2024 21:01:38 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [PATCH] c++: Export usings referring to global module fragment [PR109679] MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.3 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, T_SCC_BODY_TEXT_LINE, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787063072069895575 X-GMAIL-MSGID: 1787063072069895575 Bootstrapped & regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- This patch stops 'add_binding_entity' from ignoring all names in the global module fragment, since they should still be exported if named in an exported using-declaration. PR c++/109679 gcc/cp/ChangeLog: * module.cc (depset::hash::add_binding_entity): Don't skip names in the GMF if they've been exported with a using declaration. gcc/testsuite/ChangeLog: * g++.dg/modules/using-11.h: New test. * g++.dg/modules/using-11_a.C: New test. * g++.dg/modules/using-11_b.C: New test. Signed-off-by: Nathaniel Shead --- gcc/cp/module.cc | 6 ++++-- gcc/testsuite/g++.dg/modules/using-11.h | 2 ++ gcc/testsuite/g++.dg/modules/using-11_a.C | 9 +++++++++ gcc/testsuite/g++.dg/modules/using-11_b.C | 8 ++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/using-11.h create mode 100644 gcc/testsuite/g++.dg/modules/using-11_a.C create mode 100644 gcc/testsuite/g++.dg/modules/using-11_b.C diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 82b61a2c2ad..865a4b77eca 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -12837,8 +12837,10 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) else if (TREE_CODE (inner) == TEMPLATE_DECL) inner = DECL_TEMPLATE_RESULT (inner); - if (!DECL_LANG_SPECIFIC (inner) || !DECL_MODULE_PURVIEW_P (inner)) - /* Ignore global module fragment entities. */ + if ((!DECL_LANG_SPECIFIC (inner) || !DECL_MODULE_PURVIEW_P (inner)) + && !(flags & (WMB_Using | WMB_Export))) + /* Ignore global module fragment entities unless explicitly + exported with a using declaration. */ return false; if (VAR_OR_FUNCTION_DECL_P (inner) diff --git a/gcc/testsuite/g++.dg/modules/using-11.h b/gcc/testsuite/g++.dg/modules/using-11.h new file mode 100644 index 00000000000..64c1b0ca335 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-11.h @@ -0,0 +1,2 @@ +// PR c++/109679 +inline int foo() { return 42; } diff --git a/gcc/testsuite/g++.dg/modules/using-11_a.C b/gcc/testsuite/g++.dg/modules/using-11_a.C new file mode 100644 index 00000000000..b846bc79203 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-11_a.C @@ -0,0 +1,9 @@ +// PR c++/109679 +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi M } + +module; +#include "using-11.h" + +export module M; +export using ::foo; diff --git a/gcc/testsuite/g++.dg/modules/using-11_b.C b/gcc/testsuite/g++.dg/modules/using-11_b.C new file mode 100644 index 00000000000..736a48c98f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-11_b.C @@ -0,0 +1,8 @@ +// PR c++/109679 +// { dg-module-do link } +// { dg-additional-options "-fmodules-ts" } + +import M; +int main() { + return foo(); +}