diff options
author | Jason Merrill <jason@redhat.com> | 2024-01-09 05:15:01 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-01-11 17:01:06 -0500 |
commit | 61b493f17e6fea5a0fb45b6a050259ca326c13a7 (patch) | |
tree | 9ad8270bd387f0a92b7279c46c07aae2a03ce92a /gcc/cp/method.cc | |
parent | 9bac1d7839f129f93f159c27adaf472ee3ab23a2 (diff) | |
download | gcc-61b493f17e6fea5a0fb45b6a050259ca326c13a7.zip gcc-61b493f17e6fea5a0fb45b6a050259ca326c13a7.tar.gz gcc-61b493f17e6fea5a0fb45b6a050259ca326c13a7.tar.bz2 |
c++: corresponding object parms [PR113191]
As discussed, our handling of corresponding object parameters needed to
handle the using-declaration case better. And I took the opportunity to
share code between the add_method and cand_parms_match uses.
This patch specifically doesn't compare reversed parameters, but a follow-up
patch will.
PR c++/113191
gcc/cp/ChangeLog:
* class.cc (xobj_iobj_parameters_correspond): Add context parm.
(object_parms_correspond): Factor out of...
(add_method): ...here.
* method.cc (defaulted_late_check): Use it.
* call.cc (class_of_implicit_object): New.
(object_parms_correspond): Overload taking two candidates.
(cand_parms_match): Use it.
(joust): Check reversed before comparing constraints.
* cp-tree.h (object_parms_correspond): Declare.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-memfun4.C: New test.
Diffstat (limited to 'gcc/cp/method.cc')
-rw-r--r-- | gcc/cp/method.cc | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc index 6a9f03e..d49e5a5 100644 --- a/gcc/cp/method.cc +++ b/gcc/cp/method.cc @@ -3395,24 +3395,18 @@ defaulted_late_check (tree fn) { tree fn_obj_ref_type = TREE_VALUE (fn_parms); /* We can't default xobj operators with an xobj parameter that is not - an lvalue reference. */ + an lvalue reference, even if it would correspond. */ if (!TYPE_REF_P (fn_obj_ref_type) - || TYPE_REF_IS_RVALUE (fn_obj_ref_type)) - return false; - /* If implicit_fn's object parameter is not a pointer, something is not - right. */ - gcc_assert (TYPE_PTR_P (TREE_VALUE (implicit_fn_parms))); - /* Strip the reference/pointer off each object parameter before - comparing them. */ - if (!same_type_p (TREE_TYPE (fn_obj_ref_type), - TREE_TYPE (TREE_VALUE (implicit_fn_parms)))) + || TYPE_REF_IS_RVALUE (fn_obj_ref_type) + || !object_parms_correspond (fn, implicit_fn, + DECL_CONTEXT (implicit_fn))) return false; /* We just compared the object parameters, skip over them before passing to compparms. */ fn_parms = TREE_CHAIN (fn_parms); implicit_fn_parms = TREE_CHAIN (implicit_fn_parms); } - return compparms(fn_parms, implicit_fn_parms); + return compparms (fn_parms, implicit_fn_parms); }; if (!same_type_p (TREE_TYPE (TREE_TYPE (fn)), |