summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-02 00:36:19 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-02 00:36:19 +0000
commitd2c2d172dab8de8ed99bd5f41d78013feb117ca0 (patch)
tree3d8d4cd6cb60b214a57a30184d0c773b52358dda /clang/lib/Sema
parent55957a84907eb20df9934d33f5c00148ccc1ce16 (diff)
downloadbcm5719-llvm-d2c2d172dab8de8ed99bd5f41d78013feb117ca0.tar.gz
bcm5719-llvm-d2c2d172dab8de8ed99bd5f41d78013feb117ca0.zip
Fix bitfield promotions in several more cases. We don't seem to work hard enough at determining whether an expression is a bitfield or not, yet.
llvm-svn: 70613
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3442cc1db9f..47b9fbd7bce 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -264,6 +264,14 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr,
if (!lhs->isArithmeticType() || !rhs->isArithmeticType())
return lhs;
+ // Perform bitfield promotions.
+ QualType LHSBitfieldPromoteTy = isPromotableBitField(lhsExpr, Context);
+ if (!LHSBitfieldPromoteTy.isNull())
+ lhs = LHSBitfieldPromoteTy;
+ QualType RHSBitfieldPromoteTy = isPromotableBitField(rhsExpr, Context);
+ if (!RHSBitfieldPromoteTy.isNull())
+ rhs = RHSBitfieldPromoteTy;
+
QualType destType = UsualArithmeticConversionsType(lhs, rhs);
if (!isCompAssign)
ImpCastExprToType(lhsExpr, destType);
@@ -3475,6 +3483,12 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
QualType LHSTy = lex->getType();
if (LHSTy->isPromotableIntegerType())
LHSTy = Context.IntTy;
+ else {
+ QualType T = isPromotableBitField(lex, Context);
+ if (!T.isNull())
+ LHSTy = T;
+ }
+
*CompLHSTy = LHSTy;
}
return PExp->getType();
@@ -3628,8 +3642,11 @@ QualType Sema::CheckShiftOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
QualType LHSTy;
if (lex->getType()->isPromotableIntegerType())
LHSTy = Context.IntTy;
- else
- LHSTy = lex->getType();
+ else {
+ LHSTy = isPromotableBitField(lex, Context);
+ if (LHSTy.isNull())
+ LHSTy = lex->getType();
+ }
if (!isCompAssign)
ImpCastExprToType(lex, LHSTy);
@@ -4067,7 +4084,7 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS,
// C99 6.5.16.1p2: In simple assignment, the value of the right operand
// is converted to the type of the assignment expression (above).
// C++ 5.17p1: the type of the assignment expression is that of its left
- // oprdu.
+ // operand.
return LHSType.getUnqualifiedType();
}
OpenPOWER on IntegriCloud