Make reference class unification in conditional expressions check for validity of the conversion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70121 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 6b0c044..afd67fa 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1158,17 +1158,17 @@
       ICS.Standard.ReferenceBinding) {
     assert(ICS.Standard.DirectBinding &&
            "TryClassUnification should never generate indirect ref bindings");
-    // FIXME: Should use CheckReferenceInit here, but we no longer have a
-    // reference type.
-    Self.ImpCastExprToType(E, TargetType(ICS), true);
-    return false;
+    // FIXME: CheckReferenceInit should be able to reuse the ICS instead of
+    // redoing all the work.
+    return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType(
+                                        TargetType(ICS)));
   }
   if (ICS.ConversionKind == ImplicitConversionSequence::UserDefinedConversion &&
       ICS.UserDefined.After.ReferenceBinding) {
     assert(ICS.UserDefined.After.DirectBinding &&
            "TryClassUnification should never generate indirect ref bindings");
-    Self.ImpCastExprToType(E, TargetType(ICS), true);
-    return false;
+    return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType(
+                                        TargetType(ICS)));
   }
   if (Self.PerformImplicitConversion(E, TargetType(ICS), ICS, "converting"))
     return true;