Partial expansion of C++ operator overloading (for binary operators)
to support operators defined as member functions, e.g.,

  struct X { 
    bool operator==(X&);
  };

Overloading with non-member operators is supported, and the special
rules for the implicit object parameter (e.g., the ability for a
non-const *this to bind to an rvalue) are implemented.

This change also refactors and generalizes the code for adding
overload candidates for overloaded operator calls (C++ [over.match.expr]),
both to match the rules more exactly (name lookup of non-member
operators actually ignores member operators) and to make this routine
more reusable for the other overloaded operators.

Testing for the initialization of the implicit object parameter is
very light. More tests will come when we get support for calling
member functions directly (e.g., o.m(a1, a2)).




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59564 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 52d31c0..71d949d 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -27,4 +27,24 @@
   bool b = y - z; // expected-error{{use of overloaded operator '-' is ambiguous; candidates are:}}
 }
 
+struct A {
+  bool operator==(Z&); // expected-note{{candidate function}}
+};
 
+A make_A();
+
+bool operator==(A&, Z&); // expected-note{{candidate function}}
+
+void h(A a, const A ac, Z z) {
+  make_A() == z;
+  a == z; // expected-error{{use of overloaded operator '==' is ambiguous; candidates are:}}
+  ac == z; // expected-error{{invalid operands to binary expression ('struct A const' and 'struct Z')}}
+}
+
+struct B {
+  bool operator==(const B&) const;
+
+  void test(Z z) {
+    make_A() == z;
+  }
+};