aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-04-26 11:21:02 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-04-26 11:21:02 +0000
commita5cd2cdd11179387aa01f43cb6d6af440e006553 (patch)
tree7493d901e7c50fc540cb39df024f674610b8b6aa
parent5414fbac5f1749c0e85a8c4eeb5dfece59c3e30a (diff)
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
-rw-r--r--lib/Sema/SemaExprCXX.cpp12
-rw-r--r--test/SemaCXX/conditional-expr.cpp10
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 6b0c04440a..afd67fac55 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1158,17 +1158,17 @@ static bool ConvertForConditional(Sema &Self, Expr *&E,
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;
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index 331298dbf6..3fede303b6 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -25,7 +25,7 @@ struct Derived : Base {
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 test()
(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;