aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PPExpressions.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-05-16 21:24:10 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-05-16 21:24:10 +0000
commit3265a42e5a87269fce5d7a7cdd7bafe62c7becfe (patch)
tree149c7abbb30802f2133411018df3023e44829361 /lib/Lex/PPExpressions.cpp
parent2928c2107f2e0007f35fe1c224aab63535f1403d (diff)
PR3942: Don't warn on unsigned overflow in preprocessor expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71960 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPExpressions.cpp')
-rw-r--r--lib/Lex/PPExpressions.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp
index 0c3aa02361..47c3f8d1c7 100644
--- a/lib/Lex/PPExpressions.cpp
+++ b/lib/Lex/PPExpressions.cpp
@@ -511,7 +511,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
case tok::star:
Res = LHS.Val * RHS.Val;
- if (LHS.Val != 0 && RHS.Val != 0)
+ if (Res.isSigned() && LHS.Val != 0 && RHS.Val != 0)
Overflow = Res/RHS.Val != LHS.Val || Res/LHS.Val != RHS.Val;
break;
case tok::lessless: {
@@ -520,7 +520,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
if (ShAmt >= LHS.Val.getBitWidth())
Overflow = true, ShAmt = LHS.Val.getBitWidth()-1;
else if (LHS.isUnsigned())
- Overflow = ShAmt > LHS.Val.countLeadingZeros();
+ Overflow = false;
else if (LHS.Val.isNonNegative()) // Don't allow sign change.
Overflow = ShAmt >= LHS.Val.countLeadingZeros();
else
@@ -540,7 +540,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
case tok::plus:
Res = LHS.Val + RHS.Val;
if (LHS.isUnsigned())
- Overflow = Res.ult(LHS.Val);
+ Overflow = false;
else if (LHS.Val.isNonNegative() == RHS.Val.isNonNegative() &&
Res.isNonNegative() != LHS.Val.isNonNegative())
Overflow = true; // Overflow for signed addition.
@@ -548,7 +548,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
case tok::minus:
Res = LHS.Val - RHS.Val;
if (LHS.isUnsigned())
- Overflow = Res.ugt(LHS.Val);
+ Overflow = false;
else if (LHS.Val.isNonNegative() != RHS.Val.isNonNegative() &&
Res.isNonNegative() != LHS.Val.isNonNegative())
Overflow = true; // Overflow for signed subtraction.