diff options
author | Chris Lattner <sabre@nondot.org> | 2008-05-04 23:46:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-05-04 23:46:17 +0000 |
commit | 019ef7e1024562f9647d80ded7be8b8c1d23678a (patch) | |
tree | a41f7d76abf9ecd86ae0710e1e3044ed9b9914e3 /lib/Lex/PPExpressions.cpp | |
parent | 463ec609931b1ae9cdf71f2d1ac37237b266344d (diff) |
||/&& do not do UAC's either. This silences a bogus warning on #if -1 || 4U.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPExpressions.cpp')
-rw-r--r-- | lib/Lex/PPExpressions.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index aea203f9df..9fda8b0862 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -409,11 +409,17 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec, assert(PeekPrec <= ThisPrec && "Recursion didn't work!"); // Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if - // either operand is unsigned. Don't do this for x and y in "x ? y : z" or - // for shifts. + // either operand is unsigned. llvm::APSInt Res(LHS.getBitWidth()); - if (Operator != tok::question && Operator != tok::lessless && - Operator != tok::greatergreater && Operator != tok::comma) { + switch (Operator) { + case tok::question: // No UAC for x and y in "x ? y : z". + case tok::lessless: // Shift amount doesn't UAC with shift value. + case tok::greatergreater: // Shift amount doesn't UAC with shift value. + case tok::comma: // Comma operands are not subject to UACs. + case tok::pipepipe: // Logical || does not do UACs. + case tok::ampamp: // Logical && does not do UACs. + break; // No UAC + default: Res.setIsUnsigned(LHS.isUnsigned()|RHS.isUnsigned()); // If this just promoted something from signed to unsigned, and if the // value was negative, warn about it. |