aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/overloaded-operator.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-19 03:25:36 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-19 03:25:36 +0000
commit447b69e55e1098d8df46dd99f171bfaace9ff8a0 (patch)
tree5eb0bb0838c94e758fdf10aba2beb422fb00384b /test/SemaCXX/overloaded-operator.cpp
parent2df37b8eaecc5382e0e511a738f88918f48d9454 (diff)
Built-in equality and relational operators have return type "bool" in C++,
not "int". Fix a typo in the promotion of enumeration types that was causing some integral promotions to look like integral conversions (leading to extra ambiguities in overload resolution). Check for "acceptable" overloaded operators based on the types of the arguments. This is a somewhat odd check that is specified by the standard, but I can't see why it actually matters: the overload candidates it suppresses don't seem like they would ever be picked as the best candidates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/overloaded-operator.cpp')
-rw-r--r--test/SemaCXX/overloaded-operator.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 71d949d750..c540c2dafc 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -48,3 +48,24 @@ struct B {
make_A() == z;
}
};
+
+enum Enum1 { };
+enum Enum2 { };
+
+struct E1 {
+ E1(Enum1) { }
+};
+
+struct E2 {
+ E2(Enum2);
+};
+
+// C++ [over.match.oper]p3 - enum restriction.
+float& operator==(E1, E2);
+
+void enum_test(Enum1 enum1, Enum2 enum2, E1 e1, E2 e2) {
+ float &f1 = (e1 == e2);
+ float &f2 = (enum1 == e2);
+ float &f3 = (e1 == enum2);
+ float &f4 = (enum1 == enum2); // expected-error{{non-const reference to type 'float' cannot be initialized with a temporary of type '_Bool'}}
+}