When producing overload candidates for binary built-in operators, keep
the sets of available conversions for the first and second arguments
separate. This is apparently the indent of C++ [over.built], and
reduces the number of overload candidates generated, eliminating some
ambiguities. Fixes PR8477.

llvm-svn: 118178
diff --git a/clang/test/SemaCXX/overloaded-builtin-operators.cpp b/clang/test/SemaCXX/overloaded-builtin-operators.cpp
index 8a49671..382f5d9 100644
--- a/clang/test/SemaCXX/overloaded-builtin-operators.cpp
+++ b/clang/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -200,3 +200,23 @@
     if (e1 > e2) {}
   }
 }
+
+namespace PR8477 {
+  struct Foo {
+    operator bool();
+    operator const char *();
+  };
+
+  bool doit() {
+    Foo foo;
+    long long zero = 0;
+    (void)(foo + zero);
+    (void)(foo - zero);
+    (void)(zero + foo);
+    (void)(zero[foo]);
+    (void)(foo - foo); // expected-error{{use of overloaded operator '-' is ambiguous}} \
+    // expected-note 4{{built-in candidate operator-}} \
+    // expected-note{{candidates omitted}}
+    return foo[zero] == zero;
+  }
+}