From: Jason Merrill Date: Fri, 14 Nov 2025 17:59:38 +0000 (+0530) Subject: c++/modules: using builtin X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=feccb9c9cd6ccab3fa75e2ca3f533e02de15750f;p=thirdparty%2Fgcc.git c++/modules: using builtin 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. --- 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 + +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); +}