From: Nathaniel Shead <nathanieloshead@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Jason Merrill <jason@redhat.com>, Nathan Sidwell <nathan@acm.org>
Subject: [PATCH] c++: Export usings referring to global module fragment [PR109679]
Date: Wed, 3 Jan 2024 21:01:38 +1100 [thread overview]
Message-ID: <65953088.050a0220.d187.0c52@mx.google.com> (raw)
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 <nathanieloshead@gmail.com>
---
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();
+}
--
2.43.0
next reply other threads:[~2024-01-03 10:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 10:01 Nathaniel Shead [this message]
2024-01-06 22:25 ` Nathan Sidwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=65953088.050a0220.d187.0c52@mx.google.com \
--to=nathanieloshead@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=nathan@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).