aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-11-18 19:01:18 +0000
committerJohn McCall <rjmccall@apple.com>2010-11-18 19:01:18 +0000
commit0943168ac126b8047f30f6bd215fbe7db14d61ba (patch)
treed4e607bc4eb0ea16a0398f41710e50ef3954e53c /lib/Sema/SemaExprCXX.cpp
parentf4bed3f768a1effac21f3089f4c05f9ab9c37fe3 (diff)
Add an assertion, fix a whole bunch of bugs, comment the assertion
out because there are still bugs left. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r--lib/Sema/SemaExprCXX.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index fbd36fd61d..fde207ed38 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1601,7 +1601,7 @@ ExprResult Sema::CheckConditionVariable(VarDecl *ConditionVar,
Expr *Condition = DeclRefExpr::Create(Context, 0, SourceRange(), ConditionVar,
ConditionVar->getLocation(),
ConditionVar->getType().getNonReferenceType(),
- Expr::getValueKindForType(ConditionVar->getType()));
+ VK_LValue);
if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc))
return ExprError();
@@ -2594,6 +2594,7 @@ static bool ConvertForConditional(Sema &Self, Expr *&E, QualType T) {
/// extension. In this case, LHS == Cond. (But they're not aliases.)
QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
Expr *&SAVE, ExprValueKind &VK,
+ ExprObjectKind &OK,
SourceLocation QuestionLoc) {
// FIXME: Handle C99's complex types, vector types, block pointers and Obj-C++
// interface pointers.
@@ -2613,6 +2614,7 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
// Assume r-value.
VK = VK_RValue;
+ OK = OK_Ordinary;
// Either of the arguments dependent?
if (LHS->isTypeDependent() || RHS->isTypeDependent())
@@ -2697,15 +2699,20 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
// category and have the same type, the result is of that type and
// value category and it is a bit-field if the second or the third
// operand is a bit-field, or if both are bit-fields.
- // We can't support the bitfield parts of that correctly right now,
- // though, so we just require both sides to be ordinary values.
+ // We only extend this to bitfields, not to the crazy other kinds of
+ // l-values.
bool Same = Context.hasSameType(LTy, RTy);
if (Same &&
LHS->getValueKind() != VK_RValue &&
LHS->getValueKind() == RHS->getValueKind() &&
- LHS->getObjectKind() == OK_Ordinary &&
- RHS->getObjectKind() == OK_Ordinary) {
+ (LHS->getObjectKind() == OK_Ordinary ||
+ LHS->getObjectKind() == OK_BitField) &&
+ (RHS->getObjectKind() == OK_Ordinary ||
+ RHS->getObjectKind() == OK_BitField)) {
VK = LHS->getValueKind();
+ if (LHS->getObjectKind() == OK_BitField ||
+ RHS->getObjectKind() == OK_BitField)
+ OK = OK_BitField;
return LTy;
}