Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
Here, when we try to bring "memset" back into the global namespace, we find
the built-in, see that it's the same declaration (because the module brought
it into the other namespace with a using-declaration), and decide that we
don't need to do anything. But we still need a non-hidden overload.
gcc/cp/ChangeLog:
* name-lookup.cc (do_nonmember_using_decl): Handle hidden better.
gcc/testsuite/ChangeLog:
* g++.dg/modules/using-33_a.C: New test.
* g++.dg/modules/using-33_b.C: New test.
---
gcc/cp/name-lookup.cc | 6 +++++-
gcc/testsuite/g++.dg/modules/using-33_a.C | 10 ++++++++++
gcc/testsuite/g++.dg/modules/using-33_b.C | 10 ++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/modules/using-33_a.C
create mode 100644 gcc/testsuite/g++.dg/modules/using-33_b.C
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 984d37c2089..abb0d48fb66 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -5404,7 +5404,11 @@ do_nonmember_using_decl (name_lookup &lookup, bool
fn_scope_p,
namespace. We will still want to insert it if
it is revealing a not-revealed thing. */
found = true;
- if (!revealing_p)
+ if (old.hidden_p ())
+ /* The function was merged with a hidden built-in;
+ insert it again as not hidden. */
+ found = false;
+ else if (!revealing_p)
;
else if (old.using_p ())
{
diff --git a/gcc/testsuite/g++.dg/modules/using-33_a.C
b/gcc/testsuite/g++.dg/modules/using-33_a.C
new file mode 100644
index 00000000000..949eade2cd9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/using-33_a.C
@@ -0,0 +1,10 @@
+// { dg-additional-options "-fmodules" }
+module;
+
+#include <string.h>
+
+export module M;
+
+namespace N {
+ export using ::memset;
+}
diff --git a/gcc/testsuite/g++.dg/modules/using-33_b.C
b/gcc/testsuite/g++.dg/modules/using-33_b.C
new file mode 100644
index 00000000000..342014666ca
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/using-33_b.C
@@ -0,0 +1,10 @@
+// { dg-additional-options "-fmodules" }
+import M;
+
+using N::memset;
+
+int main()
+{
+ int i = 1;
+ memset (&i, 42, 1);
+}
base-commit: 2359344af53a5fc844d108fcf9f0e8bddd84a6b5
--
2.51.0