[gcc r15-1224] c++: repeated export using
Jason Merrill
jason@gcc.gnu.org
Wed Jun 12 20:31:14 GMT 2024
https://gcc.gnu.org/g:074c1fc797435979c00b24aff2a4f895b8273bcf
commit r15-1224-g074c1fc797435979c00b24aff2a4f895b8273bcf
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 12 08:06:47 2024 -0400
c++: repeated export using
A sample implementation of module std was breaking because the exports
included 'using std::operator&' twice. Since Nathaniel's r15-964 for
PR114867, the first using added an extra instance of each function that was
revealed/exported by that using, resulting in duplicates for
lookup_maybe_add to dedup. But if the duplicate is the first thing in the
list, lookup_add doesn't make an OVERLOAD, so trying to set OVL_USING_P
crashes. Fixed by using ovl_make in the case where we want to set the flag.
gcc/cp/ChangeLog:
* tree.cc (lookup_maybe_add): Use ovl_make when setting OVL_USING_P.
gcc/testsuite/ChangeLog:
* g++.dg/modules/using-21_a.C: New test.
Diff:
---
gcc/cp/tree.cc | 8 ++++++--
gcc/testsuite/g++.dg/modules/using-21_a.C | 11 +++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index d2a8f79ffab4..28648c14c6da 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -2526,11 +2526,15 @@ lookup_maybe_add (tree fns, tree lookup, bool deduping)
predecessors onto the lookup. */
for (; fns != probe; fns = OVL_CHAIN (fns))
{
- lookup = lookup_add (OVL_FUNCTION (fns), lookup);
/* Propagate OVL_USING, but OVL_HIDDEN &
OVL_DEDUP_P don't matter. */
if (OVL_USING_P (fns))
- OVL_USING_P (lookup) = true;
+ {
+ lookup = ovl_make (OVL_FUNCTION (fns), lookup);
+ OVL_USING_P (lookup) = true;
+ }
+ else
+ lookup = lookup_add (OVL_FUNCTION (fns), lookup);
}
/* And now skip this function. */
diff --git a/gcc/testsuite/g++.dg/modules/using-21_a.C b/gcc/testsuite/g++.dg/modules/using-21_a.C
new file mode 100644
index 000000000000..ce6e3f920f1e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/using-21_a.C
@@ -0,0 +1,11 @@
+// { dg-additional-options "-fmodules-ts -Wno-global-module" }
+
+module;
+namespace foo {
+ void baz();
+}
+export module foo;
+namespace foo {
+ export using foo::baz;
+ export using foo::baz;
+}
More information about the Gcc-cvs
mailing list