[cfe-commits] r111526 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/conversion-function.cpp

Douglas Gregor dgregor at apple.com
Thu Aug 19 10:02:01 PDT 2010


Author: dgregor
Date: Thu Aug 19 12:02:01 2010
New Revision: 111526

URL: http://llvm.org/viewvc/llvm-project?rev=111526&view=rev
Log:
We don't actually need to check the implicit object argument's
conversion a second time for a conversion candidate (with the real
acting context), because the only problems we would find are access or
ambiguity issues that won't be diagnosed until we pick this
candidate. Add a test case to prove it to myself.


Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/conversion-function.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=111526&r1=111525&r2=111526&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Aug 19 12:02:01 2010
@@ -3767,21 +3767,6 @@
     return;
   }
 
-  // Make sure that the actual object argument initialization will work, when
-  // it comes down to it. This takes into account the actual acting context.
-  if (ConversionContext->getCanonicalDecl()
-                                        != ActingContext->getCanonicalDecl()) {
-    ImplicitConversionSequence ObjectConvertICS
-      = TryObjectArgumentInitialization(From->getType(), Conversion, 
-                                        ActingContext);
-    if (ObjectConvertICS.isBad()) {
-      Candidate.Viable = false;
-      Candidate.FailureKind = ovl_fail_bad_conversion;
-      Candidate.Conversions[0] = ObjectConvertICS;
-      return;
-    }
-  }
-  
   // We won't go through a user-define type conversion function to convert a 
   // derived to base as such conversions are given Conversion Rank. They only
   // go through a copy constructor. 13.3.3.1.2-p4 [over.ics.user]

Modified: cfe/trunk/test/SemaCXX/conversion-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion-function.cpp?rev=111526&r1=111525&r2=111526&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conversion-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion-function.cpp Thu Aug 19 12:02:01 2010
@@ -306,4 +306,22 @@
   void test2(UeberDerived ud) {
     int i = ud; // expected-error{{ambiguous conversion from derived class 'rdar8018274::SuperDerived' to base class 'rdar8018274::Base'}}
   }
+
+  struct Base2 {
+    operator int();
+  };
+
+  struct Base3 {
+    operator int();
+  };
+
+  struct Derived23 : Base2, Base3 { 
+    using Base2::operator int;
+  };
+
+  struct ExtraDerived23 : Derived23 { };
+
+  void test3(ExtraDerived23 ed) {
+    int i = ed;
+  }
 }





More information about the cfe-commits mailing list