summaryrefslogtreecommitdiffstats
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
commitf79d397081e8228440d60110363b1e5ecc8057b9 (patch)
tree5f5f1c4ce9f57e1e6dd003f29861253876491288
parentc26ed54e06a48ed08202673b9c0039dd47ac5804 (diff)
downloadbcm5719-llvm-f79d397081e8228440d60110363b1e5ecc8057b9.tar.gz
bcm5719-llvm-f79d397081e8228440d60110363b1e5ecc8057b9.zip
Make reference class unification in conditional expressions check for validity of the conversion.
llvm-svn: 70121
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp12
-rw-r--r--clang/test/SemaCXX/conditional-expr.cpp10
2 files changed, 11 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 6b0c04440a8..afd67fac559 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/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/clang/test/SemaCXX/conditional-expr.cpp b/clang/test/SemaCXX/conditional-expr.cpp
index 331298dbf63..3fede303b64 100644
--- a/clang/test/SemaCXX/conditional-expr.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud