summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-04-17 16:30:52 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-04-17 16:30:52 +0000
commit5775af1afd5059282fbe18f0075a9b22010ab37a (patch)
treec5c78c1756174f92f7df3e66e2d53b39abddf4b1 /clang/lib/Sema/SemaExprCXX.cpp
parent22fa407ed71eb3167879cb8fe4b0e698c4d1be6e (diff)
downloadbcm5719-llvm-5775af1afd5059282fbe18f0075a9b22010ab37a.tar.gz
bcm5719-llvm-5775af1afd5059282fbe18f0075a9b22010ab37a.zip
Implement lvalue test for conditional expressions.
Add a few commented lines to the test case that point out things that don't work yet. llvm-svn: 69354
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8f41c003f95..0539caa712f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1137,6 +1137,35 @@ static bool FindConditionalOverload(Sema &Self, Expr *&LHS, Expr *&RHS,
return true;
}
+/// \brief Perform an "extended" implicit conversion as returned by
+/// TryClassUnification.
+///
+/// TryClassUnification generates ICSs that include reference bindings.
+/// PerformImplicitConversion is not suitable for this; it chokes if the
+/// second part of a standard conversion is ICK_DerivedToBase. This function
+/// handles the reference binding specially.
+static bool ConvertForConditional(Sema &Self, Expr *&E,
+ const ImplicitConversionSequence &ICS)
+{
+ if (ICS.ConversionKind == ImplicitConversionSequence::StandardConversion &&
+ ICS.Standard.ReferenceBinding) {
+ assert(ICS.Standard.DirectBinding &&
+ "TryClassUnification should never generate indirect ref bindings");
+ Self.ImpCastExprToType(E, TargetType(ICS), true);
+ return false;
+ }
+ 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;
+ }
+ if (Self.PerformImplicitConversion(E, TargetType(ICS), ICS, "converting"))
+ return true;
+ return false;
+}
+
/// \brief Check the operands of ?: under C++ semantics.
///
/// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
@@ -1223,13 +1252,11 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
// the chosen operand and the converted operands are used in place of the
// original operands for the remainder of this section.
if (HaveL2R) {
- if (PerformImplicitConversion(LHS, TargetType(ICSLeftToRight),
- ICSLeftToRight, "converting"))
+ if (ConvertForConditional(*this, LHS, ICSLeftToRight))
return QualType();
LTy = LHS->getType();
} else if (HaveR2L) {
- if (PerformImplicitConversion(RHS, TargetType(ICSRightToLeft),
- ICSRightToLeft, "converting"))
+ if (ConvertForConditional(*this, RHS, ICSRightToLeft))
return QualType();
RTy = RHS->getType();
}
OpenPOWER on IntegriCloud