aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2024-01-09 16:00:52 -0500
committerJason Merrill <jason@redhat.com>2024-01-09 16:04:09 -0500
commit5a6d3b1737843aa64d83ffc5d639fa0afa5d8318 (patch)
treeae79a46ef382579cbb5ca1cde6406d9ce2c5d269 /gcc/cp
parentbfad006b88ec26e91b7edf9cf9ad4aaf9b8a9727 (diff)
downloadgcc-5a6d3b1737843aa64d83ffc5d639fa0afa5d8318.zip
gcc-5a6d3b1737843aa64d83ffc5d639fa0afa5d8318.tar.gz
gcc-5a6d3b1737843aa64d83ffc5d639fa0afa5d8318.tar.bz2
c++: explicit object cleanups
The FIXME in xobj_iobj_parameters_correspond was due to expecting TYPE_MAIN_VARIANT to be the same for all equivalent types, which is not the case. And I adjusted some comments that I disagree with; the iobj parameter adjustment only applies to overload resolution, we can handle that in cand_parms_match (and I have WIP for that). gcc/cp/ChangeLog: * call.cc (build_over_call): Refactor handle_arg lambda. * class.cc (xobj_iobj_parameters_correspond): Fix FIXME. * method.cc (defaulted_late_check): Adjust comments.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/call.cc24
-rw-r--r--gcc/cp/class.cc40
-rw-r--r--gcc/cp/method.cc7
3 files changed, 25 insertions, 46 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index dca8e50..7d3d676 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -10187,11 +10187,11 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
parm = TREE_CHAIN (parm);
}
- auto handle_arg = [fn, flags, complain](tree type,
- tree arg,
- int const param_index,
- conversion *conv,
- bool const conversion_warning)
+ auto handle_arg = [fn, flags](tree type,
+ tree arg,
+ int const param_index,
+ conversion *conv,
+ tsubst_flags_t const arg_complain)
{
/* Set user_conv_p on the argument conversions, so rvalue/base handling
knows not to allow any more UDCs. This needs to happen after we
@@ -10199,9 +10199,6 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
if (flags & LOOKUP_NO_CONVERSION)
conv->user_conv_p = true;
- tsubst_flags_t const arg_complain
- = conversion_warning ? complain : complain & ~tf_warning;
-
if (arg_complain & tf_warning)
maybe_warn_pessimizing_move (arg, type, /*return_p=*/false);
@@ -10214,13 +10211,12 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
if (DECL_XOBJ_MEMBER_FUNCTION_P (fn))
{
gcc_assert (cand->num_convs > 0);
- static constexpr bool conversion_warning = true;
tree object_arg = consume_object_arg ();
val = handle_arg (TREE_VALUE (parm),
object_arg,
param_index++,
convs[conv_index++],
- conversion_warning);
+ complain);
if (val == error_mark_node)
return error_mark_node;
@@ -10260,11 +10256,14 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
&& cand->template_decl
&& !cand->explicit_targs);
+ tsubst_flags_t const arg_complain
+ = conversion_warning ? complain : complain & ~tf_warning;
+
val = handle_arg (TREE_VALUE (parm),
current_arg,
param_index,
convs[conv_index],
- conversion_warning);
+ arg_complain);
if (val == error_mark_node)
return error_mark_node;
@@ -10273,7 +10272,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
}
/* Default arguments */
- for (; parm && parm != void_list_node; parm = TREE_CHAIN (parm), param_index++)
+ for (; parm && parm != void_list_node;
+ parm = TREE_CHAIN (parm), param_index++)
{
if (TREE_VALUE (parm) == error_mark_node)
return error_mark_node;
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index f3cfa9f..e5e609b 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -1020,9 +1020,12 @@ modify_vtable_entry (tree t,
/* Check if the object parameters of an xobj and iobj member function
- correspond. This function assumes that the iobj parameter has been correctly
- adjusted when the function is introduced by a using declaration per
- [over.match.funcs.general.4]. */
+ correspond. This function assumes that the iobj parameter has been
+ correctly adjusted when the function is introduced by a using declaration
+ per [over.match.funcs.general.4].
+
+ ??? But it isn't, that's only considered at overload resolution time.
+ cand_parms_match will probably need to check cand->conversion_path. */
bool
xobj_iobj_parameters_correspond (tree fn1, tree fn2)
@@ -1112,29 +1115,10 @@ xobj_iobj_parameters_correspond (tree fn1, tree fn2)
handles xobj parameters of pointer type, we don't have to explicitly
check for that case. */
- /* FIXME:
-
- template<typename>
- struct S;
-
- template<typename>
- struct B {
- int f(this S<void>&) requires true { return 5; }
- };
-
- template<typename>
- struct S : B<void> {
- using B<void>::f;
- int f() { return 10; }
- };
-
- This case is broken, the incomplete type seems to screw with things.
- I'm not sure how to fix that so I'm just noting the issue here, I have a
- feeling it's trivial to do if you know how. */
-
- if (TYPE_MAIN_VARIANT (iobj_param_type)
- != TYPE_MAIN_VARIANT (non_reference (xobj_param)))
+ if (!same_type_ignoring_top_level_qualifiers_p
+ (iobj_param_type, non_reference (xobj_param)))
return false;
+
/* We don't get to bail yet even if we have a by-value xobj parameter,
a by-value xobj parameter can correspond to an iobj parameter provided the
iobj member function is not declared with a reference qualifier.
@@ -8976,9 +8960,9 @@ resolve_address_of_overloaded_function (tree target_type,
documentation for -fms-extensions states it's purpose is to support
the use of microsoft headers. Until otherwise demonstrated, we should
assume xobj member functions are not used in this manner in microsoft
- headers and indiscriminately forbid the incorrect syntax instead of
- supporting it for non-legacy uses. This should hopefully encourage
- conformance going forward.
+ headers and forbid the incorrect syntax instead of supporting it for
+ non-legacy uses. This should hopefully encourage conformance going
+ forward.
This comment is referred to in typeck.cc:cp_build_addr_expr_1. */
if (DECL_IOBJ_MEMBER_FUNCTION_P (fn) && flag_ms_extensions)
/* Early escape. */;
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index da6a08a..6a9f03e 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -3400,8 +3400,7 @@ defaulted_late_check (tree fn)
|| TYPE_REF_IS_RVALUE (fn_obj_ref_type))
return false;
/* If implicit_fn's object parameter is not a pointer, something is not
- right. (Or we have finally changed the type of the iobj parameter
- in iobj member functions.) */
+ right. */
gcc_assert (TYPE_PTR_P (TREE_VALUE (implicit_fn_parms)));
/* Strip the reference/pointer off each object parameter before
comparing them. */
@@ -3422,10 +3421,6 @@ defaulted_late_check (tree fn)
{
error ("defaulted declaration %q+D does not match the "
"expected signature", fn);
- /* FIXME: If the user is defaulting an xobj member function we should
- emit an xobj member function for a signature. When we do this, maybe
- we can just synthesize implicit_fn as an xobj member function and
- avoid the dance in compare_fn_parms. */
inform (DECL_SOURCE_LOCATION (fn),
"expected signature: %qD", implicit_fn);
}