Do overload resolution for compound assignment even if only the RHS is overloadable. Compound assignment may be overloaded as a non-member, and anyway the overload resolution is necessary because it triggers implicit (used-defined) conversions. Fixes PR5512, but not really the deeper issues lurking. Those are standard defects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89268 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 5fdbeeb..16d3704 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -296,3 +296,31 @@
const char* a() { return sMoveCommands[X][0][0]; }
const char* b() { return (*(sMoveCommands+X))[0][0]; }
}
+
+// PR5512 and its discussion
+namespace pr5512 {
+ struct Y {
+ operator short();
+ operator float();
+ };
+ void g_test(Y y) {
+ short s = 0;
+ // DR507, this should be ambiguous, but we special-case assignment
+ s = y;
+ // Note: DR507, this is ambiguous as specified
+ //s += y;
+ }
+
+ struct S {};
+ void operator +=(int&, S);
+ void f(S s) {
+ int i = 0;
+ i += s;
+ }
+
+ struct A {operator int();};
+ int a;
+ void b(A x) {
+ a += x;
+ }
+}