Properly implement the part of C++ [over.match.funcs]p4 that treats
conversion functions as if their acting context were the class that
we're converting from (the implicit object argument's
type). Retroactively tweaking the implicit conversion sequence, as we
were trying to do before, breaks the invariants of that implicit
conversion sequence (e.g., the types and conversions don't match
up). Fixes <rdar://problem/8018274>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111520 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index 951cdb3..3d544ae 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -270,3 +270,40 @@
fake_memcpy(ptr);
}
}
+
+namespace rdar8018274 {
+ struct X { };
+ struct Y {
+ operator const struct X *() const;
+ };
+
+ struct Z : Y {
+ operator struct X * ();
+ };
+
+ void test() {
+ Z x;
+ (void) (x != __null);
+ }
+
+
+ struct Base {
+ operator int();
+ };
+
+ struct Derived1 : Base { };
+
+ struct Derived2 : Base { };
+
+ struct SuperDerived : Derived1, Derived2 {
+ using Derived1::operator int;
+ };
+
+ struct UeberDerived : SuperDerived {
+ operator long();
+ };
+
+ void test2(UeberDerived ud) {
+ int i = ud; // expected-error{{ambiguous conversion from derived class 'rdar8018274::SuperDerived' to base class 'rdar8018274::Base'}}
+ }
+}