My
r16-3559-gc2e567a6edb563 reworked ADL for modules, including a change
to allow seeing module-linkage declarations if they only exist on the
instantiation path. This caused a crash however as I neglected to
unwrap the stat hack wrapper when we were happy to see all declarations,
allowing search_adl to add non-functions to the overload set.
PR c++/121893
gcc/cp/ChangeLog:
* name-lookup.cc (name_lookup::adl_namespace_fns): Unwrap the
STAT_HACK also when on_inst_path.
gcc/testsuite/ChangeLog:
* g++.dg/modules/adl-10_a.C: New test.
* g++.dg/modules/adl-10_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
/* For lookups on the instantiation path we can see any
module-linkage declaration; otherwise we should only
see exported decls. */
- if (!on_inst_path)
+ if (on_inst_path)
+ bind = STAT_DECL (bind);
+ else
bind = STAT_VISIBLE (bind);
}
--- /dev/null
+// PR c++/121893
+// { dg-additional-options "-fmodules -Wno-global-module" }
+// { dg-module-cmi M }
+
+module;
+namespace ns {
+ struct S {};
+
+ struct F {
+ template <typename T> void operator()(T) {}
+ };
+ inline constexpr F foo{};
+}
+
+export module M;
+
+namespace ns {
+ export using ns::S;
+ export using ns::foo;
+}
+
+template <typename T> void foo(T) {}
+export template <typename T> void go(T t) { foo(t); }
--- /dev/null
+// PR c++/121893
+// { dg-additional-options "-fmodules" }
+
+import M;
+int main() {
+ ::go(ns::S{});
+}