From: Nathaniel Shead Date: Sat, 1 Nov 2025 11:59:33 +0000 (+1100) Subject: c++/modules: Stream BASELINK_OPTYPE [PR122381] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b466450c6d502557921f03527cc165fb3402aaa9;p=thirdparty%2Fgcc.git c++/modules: Stream BASELINK_OPTYPE [PR122381] 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 --- diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 81357a86cfe..31f5c8146d6 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -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 index 00000000000..62bb2101f69 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/convop-2_a.H @@ -0,0 +1,10 @@ +// PR c++/122381 +// { dg-additional-options "-fmodule-header" } +// { dg-module-cmi {} } + +template 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 index 00000000000..d1e829ec70c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/convop-2_b.C @@ -0,0 +1,5 @@ +// PR c++/122381 +// { dg-additional-options "-fmodules" } + +import "convop-2_a.H"; +template struct color_ref;