]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/modules: using builtin
authorJason Merrill <jason@redhat.com>
Fri, 14 Nov 2025 17:59:38 +0000 (23:29 +0530)
committerJason Merrill <jason@redhat.com>
Sat, 15 Nov 2025 06:11:56 +0000 (11:41 +0530)
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
gcc/testsuite/g++.dg/modules/using-33_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/using-33_b.C [new file with mode: 0644]

index 984d37c2089f2c7eac3794f52e1aed5ce7ff0609..abb0d48fb6660c77753b0df9f2882500455d7921 100644 (file)
@@ -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 (file)
index 0000000..949eade
--- /dev/null
@@ -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 (file)
index 0000000..3420146
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-additional-options "-fmodules" }
+import M;
+
+using N::memset;
+
+int main()
+{
+  int i = 1;
+  memset (&i, 42, 1);
+}