Standard conversion sequences now have a CopyConstructor field, to
cope with the case where a user-defined conversion is actually a copy
construction, and therefore can be compared against other standard
conversion sequences. While I called this a hack before, now I'm
convinced that it's the right way to go.

Compare overloads based on derived-to-base conversions that invoke
copy constructors. 

Suppress user-defined conversions when attempting to call a
user-defined conversion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58629 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 7035223..1100e70 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -931,9 +931,13 @@
 /// errors are found. Either way, a return value of true indicates
 /// that there was a failure, a return value of false indicates that
 /// the reference initialization succeeded.
+///
+/// When @p SuppressUserConversions, user-defined conversions are
+/// suppressed.
 bool 
 Sema::CheckReferenceInit(Expr *&Init, QualType &DeclType, 
-                         ImplicitConversionSequence *ICS) {
+                         ImplicitConversionSequence *ICS,
+                         bool SuppressUserConversions) {
   assert(DeclType->isReferenceType() && "Reference init needs a reference");
 
   QualType T1 = DeclType->getAsReferenceType()->getPointeeType();
@@ -1114,7 +1118,7 @@
     ///   the argument expression. Any difference in top-level
     ///   cv-qualification is subsumed by the initialization itself
     ///   and does not constitute a conversion.
-    *ICS = TryImplicitConversion(Init, T1);
+    *ICS = TryImplicitConversion(Init, T1, SuppressUserConversions);
     return ICS->ConversionKind == ImplicitConversionSequence::BadConversion;
   } else {
     return PerformImplicitConversion(Init, T1);