diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-09-20 15:41:42 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-09-20 15:41:42 -0400 |
commit | 1f70503232d4183b4b58f2910c460569d05907b9 (patch) | |
tree | ba58487d89b35259b1076af9762e10d5571a89b2 /gcc/cp | |
parent | 2828ec526eaf5612178b62d48bfd8443c7ecd674 (diff) | |
download | gcc-1f70503232d4183b4b58f2910c460569d05907b9.zip gcc-1f70503232d4183b4b58f2910c460569d05907b9.tar.gz gcc-1f70503232d4183b4b58f2910c460569d05907b9.tar.bz2 |
c++: CWG 2789 and reversed operator candidates
As a follow-up to r15-3741-gee3efe06c9c49c, which was specifically
concerned with usings, it seems the CWG 2789 refinement should also
compare contexts of a reversed vs non-reversed (member) candidate
during operator overload resolution.
DR 2789
gcc/cp/ChangeLog:
* call.cc (cand_parms_match): Check for matching class contexts
even in the reversed case.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-memfun4.C: Adjust expected result
involving reversed candidate.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/call.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index f2ce508..70783ba 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -12865,10 +12865,6 @@ cand_parms_match (z_candidate *c1, z_candidate *c2, pmatch match_kind) } } - else if (reversed) - return (reversed_match (c1, c2) - && reversed_match (c2, c1)); - tree parms1 = TYPE_ARG_TYPES (TREE_TYPE (fn1)); tree parms2 = TYPE_ARG_TYPES (TREE_TYPE (fn2)); @@ -12880,6 +12876,10 @@ cand_parms_match (z_candidate *c1, z_candidate *c2, pmatch match_kind) if (base1 != base2) return false; + if (reversed) + return (reversed_match (c1, c2) + && reversed_match (c2, c1)); + /* Use object_parms_correspond to simplify comparing iobj/xobj/static member functions. */ if (!object_parms_correspond (fn1, fn2, base1)) @@ -12897,6 +12897,9 @@ cand_parms_match (z_candidate *c1, z_candidate *c2, pmatch match_kind) parms1 = skip_parms (fn1, parms1); parms2 = skip_parms (fn2, parms2); } + else if (reversed) + return (reversed_match (c1, c2) + && reversed_match (c2, c1)); return compparms (parms1, parms2); } |