[cfe-commits] r70121 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/conditional-expr.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Sun Apr 26 04:21:10 PDT 2009


Author: cornedbee
Date: Sun Apr 26 06:21:02 2009
New Revision: 70121

URL: http://llvm.org/viewvc/llvm-project?rev=70121&view=rev
Log:
Make reference class unification in conditional expressions check for validity of the conversion.

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaCXX/conditional-expr.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=70121&r1=70120&r2=70121&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Apr 26 06:21:02 2009
@@ -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;

Modified: cfe/trunk/test/SemaCXX/conditional-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conditional-expr.cpp?rev=70121&r1=70120&r2=70121&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/conditional-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/conditional-expr.cpp Sun Apr 26 06:21:02 2009
@@ -25,7 +25,7 @@
   void fn2();
 };
 struct Convertible { operator Base&(); };
-struct Priv : private Base {};
+struct Priv : private Base {}; // expected-note 2 {{'private' inheritance specifier here}}
 struct Mid : Base {};
 struct Fin : Mid, Derived {};
 typedef void (Derived::*DFnPtr)();
@@ -116,10 +116,10 @@
   (void)(i1 ? Priv() : Base()); // xpected-error private base
   (void)(i1 ? Base() : Fin()); // xpected-error ambiguous base
   (void)(i1 ? Fin() : Base()); // xpected-error ambiguous base
-  (void)(i1 ? base : priv); // xpected-error private base
-  (void)(i1 ? priv : base); // xpected-error private base
-  (void)(i1 ? base : fin); // xpected-error ambiguous base
-  (void)(i1 ? fin : base); // xpected-error ambiguous base
+  (void)(i1 ? base : priv); // expected-error {{conversion from 'struct Priv' to inaccessible base class 'struct Base'}}
+  (void)(i1 ? priv : base); // expected-error {{conversion from 'struct Priv' to inaccessible base class 'struct Base'}}
+  (void)(i1 ? base : fin); // expected-error {{ambiguous conversion from derived class 'struct Fin' to base class 'struct Base'}}
+  (void)(i1 ? fin : base); // expected-error {{ambiguous conversion from derived class 'struct Fin' to base class 'struct Base'}}
 
   // b2.2 (non-hierarchy)
   i1 = i1 ? I() : i1;





More information about the cfe-commits mailing list