This implements a more comprehensive fix than was done at D95409.
Instead of excluding just function pointer subobjects, we also
exclude any user-defined function pointer conversion operators.
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Paths
| Differential D103855
[clang] Exclude function pointers on DefaultedComparisonAnalyzer ClosedPublic Authored by mizvekov on Jun 7 2021, 4:51 PM.
Details Summary This implements a more comprehensive fix than was done at D95409. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Diff Detail
Event TimelineHerald added subscribers: manas, steakhal, ASDenysPetrov and 5 others. · View Herald TranscriptJun 7 2021, 4:51 PM Comment Actions I think we need to take this to the C++ committee. For example, consider a case like: struct A { using T1 = void(*)(); using T2 = int; operator T1(); operator T2(); }; struct B { A a; friend auto operator<=>(B, B) = default; }; Under the standard rules, the operator<=> is deleted due to ambiguity, but with this change we'd unambiguously pick the conversion to T2. The old behavior here better matches the current standard wording -- in particular, the special case is in [class.compare.default]/3.2 and only applies when neither operand is of overloadable type -- but perhaps the right approach here would be to fix the language rules so that operator<=> is only provided for object pointer types, not for all pointer types, in general. Comment Actions I see. I can change this patch so it just implicitly deletes the operator in case we decide to pick function pointers, without the hard error introduced by the previous patch. Comment Actions Instead of excluding function pointers from the overload set, just implicitly delete Comment Actions Thanks, let's go with this for now. Discussion in WG21 seems to be heading towards removing the builtin candidates for operator<=>, operator<, operator<=, operator>, and operator>= for function pointers, but we'll probably not have a firm decision on that for quite a while. This revision is now accepted and ready to land.Jun 17 2021, 1:03 PM mizvekov removed a parent revision: D103850: [clang] diagnose instead of assert for defaulted comparison return type deduction.. This revision was landed with ongoing or failed builds.Jun 18 2021, 4:07 AM Closed by commit rG7ddd15cd5dea: [clang] Exclude function pointers on DefaultedComparisonAnalyzer (authored by mizvekov). · Explain Why This revision was automatically updated to reflect the committed changes. Comment Actions Disregard 80f30a6b855b: I messed up a copy-paste of a commit message. That was for https://reviews.llvm.org/D104480.
Revision Contents
Diff 352971 clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
|