summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2020-01-30 17:11:47 -0800
committerRichard Smith <richard@metafoo.co.uk>2020-02-04 12:25:40 -0800
commit7a94fc09d17bc317032eb9605eba05dced8c87e5 (patch)
treedf6513fb5b8d64f4340ab0f0e3c9983e420baf50 /clang/test
parent300cbdc59da05756f7a0334338076124536df03d (diff)
downloadbcm5719-llvm-7a94fc09d17bc317032eb9605eba05dced8c87e5.tar.gz
bcm5719-llvm-7a94fc09d17bc317032eb9605eba05dced8c87e5.zip
PR44721: Don't consider overloaded operators for built-in comparisons
when building a defaulted comparison. As a convenient way of asking whether `x @ y` is valid and building it, we previouly always performed overload resolution and built an overloaded expression, which would both end up picking a builtin operator candidate when given a non-overloadable type. But that's not quite right, because it can result in our finding a user-declared operator overload, which we should never do when applying operators non-overloadable types. Handle this more correctly: skip overload resolution when building `x @ y` if the operands are not overloadable. But still perform overload resolution (considering only builtin candidates) when checking validity, as we don't have any other good way to ask whether a binary operator expression would be valid. (cherry picked from commit 1f3f8c369a5067a132c871f33a955a7feaea8534)
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/class/class.compare/class.compare.default/p3.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p3.cpp b/clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
index 3d0ab2c5bde..81a48a393a0 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
@@ -190,3 +190,15 @@ bool operator<(const G&, const G&);
bool operator<=(const G&, const G&);
bool operator>(const G&, const G&);
bool operator>=(const G&, const G&);
+
+namespace PR44721 {
+ template <typename T> bool operator==(T const &, T const &) { return true; }
+ template <typename T, typename U> bool operator!=(T const &, U const &) { return true; }
+ template <typename T> int operator<=>(T const &, T const &) { return 0; }
+
+ struct S {
+ friend bool operator==(const S &, const S &) = default;
+ friend bool operator<=>(const S &, const S &) = default;
+ int x;
+ };
+}
OpenPOWER on IntegriCloud