aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 93066a288f..bb31507c23 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -6010,32 +6010,33 @@ QualType Sema::CheckAdditionOperands( // C99 6.5.6
if (IExp->getType()->isAnyPointerType())
std::swap(PExp, IExp);
- if (PExp->getType()->isAnyPointerType()) {
- if (IExp->getType()->isIntegerType()) {
- if (!checkArithmeticOpPointerOperand(*this, Loc, PExp))
- return QualType();
+ if (!PExp->getType()->isAnyPointerType())
+ return InvalidOperands(Loc, LHS, RHS);
- // Diagnose bad cases where we step over interface counts.
- if (!checkArithmethicPointerOnNonFragileABI(*this, Loc, PExp))
- return QualType();
+ if (!IExp->getType()->isIntegerType())
+ return InvalidOperands(Loc, LHS, RHS);
- // Check array bounds for pointer arithemtic
- CheckArrayAccess(PExp, IExp);
-
- if (CompLHSTy) {
- QualType LHSTy = Context.isPromotableBitField(LHS.get());
- if (LHSTy.isNull()) {
- LHSTy = LHS.get()->getType();
- if (LHSTy->isPromotableIntegerType())
- LHSTy = Context.getPromotedIntegerType(LHSTy);
- }
- *CompLHSTy = LHSTy;
- }
- return PExp->getType();
+ if (!checkArithmeticOpPointerOperand(*this, Loc, PExp))
+ return QualType();
+
+ // Diagnose bad cases where we step over interface counts.
+ if (!checkArithmethicPointerOnNonFragileABI(*this, Loc, PExp))
+ return QualType();
+
+ // Check array bounds for pointer arithemtic
+ CheckArrayAccess(PExp, IExp);
+
+ if (CompLHSTy) {
+ QualType LHSTy = Context.isPromotableBitField(LHS.get());
+ if (LHSTy.isNull()) {
+ LHSTy = LHS.get()->getType();
+ if (LHSTy->isPromotableIntegerType())
+ LHSTy = Context.getPromotedIntegerType(LHSTy);
}
+ *CompLHSTy = LHSTy;
}
- return InvalidOperands(Loc, LHS, RHS);
+ return PExp->getType();
}
// C99 6.5.6