]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/modules: Add testcase for lookup of hidden friend [PR122646]
authorNathaniel Shead <nathanieloshead@gmail.com>
Thu, 13 Nov 2025 22:11:25 +0000 (09:11 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Thu, 13 Nov 2025 22:19:23 +0000 (09:19 +1100)
r16-5173-g52a24bcec9388a fixed this testcase, but I think it's
worthwhile still adding this reduced test for it to the modules.exp set
of tests so we don't need to rely on libstdc++ tests for it yet.

PR c++/122646

gcc/testsuite/ChangeLog:

* g++.dg/modules/friend-10_a.C: New test.
* g++.dg/modules/friend-10_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/testsuite/g++.dg/modules/friend-10_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/friend-10_b.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/modules/friend-10_a.C b/gcc/testsuite/g++.dg/modules/friend-10_a.C
new file mode 100644 (file)
index 0000000..6669fff
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/122646
+// { dg-additional-options "-fmodules -fconcepts" }
+// { dg-module-cmi M }
+
+export module M;
+
+template <typename T>
+struct zip_view_iterator {
+  void operator-(int) {}
+  friend void operator-(zip_view_iterator, zip_view_iterator)
+    requires requires(T x) { x.begin() - x.begin(); }
+  {}
+};
+
+struct ref_view {
+  ref_view begin();
+};
+
+export template <typename X> void foo() {
+  zip_view_iterator<ref_view>{} - X();
+}
diff --git a/gcc/testsuite/g++.dg/modules/friend-10_b.C b/gcc/testsuite/g++.dg/modules/friend-10_b.C
new file mode 100644 (file)
index 0000000..ea261aa
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/122646
+// { dg-additional-options "-fmodules -fconcepts" }
+
+import M;
+template void foo<int>();