]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/modules: Stream BASELINK_OPTYPE [PR122381]
authorNathaniel Shead <nathanieloshead@gmail.com>
Sat, 1 Nov 2025 11:59:33 +0000 (22:59 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 1 Nov 2025 12:02:38 +0000 (23:02 +1100)
This is used in template conversion operators to determine what type the
user requested.

PR c++/122381

gcc/cp/ChangeLog:

* module.cc (trees_out::core_vals): Write BASELINK_OPTYPE (aka
TREE_CHAIN).
(trees_in::core_vals): Read it.

gcc/testsuite/ChangeLog:

* g++.dg/modules/convop-2_a.H: New test.
* g++.dg/modules/convop-2_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/convop-2_a.H [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/convop-2_b.C [new file with mode: 0644]

index 81357a86cfe8bd6d6bb135cbf892c381e4ec9172..31f5c8146d62599dc6317159741e25597a94cfbc 100644 (file)
@@ -6733,6 +6733,7 @@ trees_out::core_vals (tree t)
       WT (((lang_tree_node *)t)->baselink.binfo);
       WT (((lang_tree_node *)t)->baselink.functions);
       WT (((lang_tree_node *)t)->baselink.access_binfo);
+      WT (((lang_tree_node *)t)->baselink.common.chain);
       break;
 
     case CONSTRAINT_INFO:
@@ -7302,6 +7303,7 @@ trees_in::core_vals (tree t)
       RT (((lang_tree_node *)t)->baselink.binfo);
       RTU (((lang_tree_node *)t)->baselink.functions);
       RT (((lang_tree_node *)t)->baselink.access_binfo);
+      RT (((lang_tree_node *)t)->baselink.common.chain);
       break;
 
     case CONSTRAINT_INFO:
diff --git a/gcc/testsuite/g++.dg/modules/convop-2_a.H b/gcc/testsuite/g++.dg/modules/convop-2_a.H
new file mode 100644 (file)
index 0000000..62bb210
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/122381
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+template <typename T> struct color_ref {
+  operator int() const { return 0; }
+  int foo(color_ref x) {
+    return x.operator int();
+  }
+};
diff --git a/gcc/testsuite/g++.dg/modules/convop-2_b.C b/gcc/testsuite/g++.dg/modules/convop-2_b.C
new file mode 100644 (file)
index 0000000..d1e829e
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/122381
+// { dg-additional-options "-fmodules" }
+
+import "convop-2_a.H";
+template struct color_ref<int>;