On 3/5/24 17:47, Nathaniel Shead wrote:
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?
-- >8 --
Unification for conversion operators (DEDUCE_CONV) doesn't perform
transformations like handling forwarding references. This is correct in
general, but not for xobj parameters, which should be handled "normally"
for the purposes of deduction: [temp.deduct.conv] only applies to the
return type of the conversion function.
PR c++/113629
gcc/cp/ChangeLog:
* pt.cc (type_unification_real): Use DEDUCE_CALL for xobj
parameters of conversion functions.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/explicit-obj-conv-op.C: New test.
Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
---
gcc/cp/pt.cc | 15 +++++-
.../g++.dg/cpp23/explicit-obj-conv-op.C | 49 +++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/cpp23/explicit-obj-conv-op.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index c4bc54a8fdb..632437d3424 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -23281,6 +23281,10 @@ type_unification_real (tree tparms,
in TARGS. */
NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs) = NULL_TREE;
+ bool is_xobj_conv_fn
+ = (strict == DEDUCE_CONV
+ && DECL_XOBJ_MEMBER_FUNCTION_P (TREE_TYPE (tparms)));
+
again:
parms = xparms;
args = xargs;
@@ -23312,10 +23316,17 @@ type_unification_real (tree tparms,
parameter pack is a non-deduced context. */
continue;
+ /* For explicit object parameters, unification should behave like
+ normal function calls, even for conversion functions. This
+ corresponds to the second (that is, last) argument. */
+ unification_kind_t kind = strict;
+ if (is_xobj_conv_fn && ia > 0)
Is it necessary to check the xobj flag? Or can this just be
if (strict == DEDUCE_CONV && ia > 0)
?
Jason