summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-05-04 23:46:17 +0000
committerChris Lattner <sabre@nondot.org>2008-05-04 23:46:17 +0000
commitca671b0e5144910731d9ff266a60c8b37dfee8b1 (patch)
treec07d0aad43faecd0453372c10b0804f3fe17741f /clang/lib/Lex
parent4af72c76dd58c22563af0f96b778249ad69f3e79 (diff)
downloadbcm5719-llvm-ca671b0e5144910731d9ff266a60c8b37dfee8b1.tar.gz
bcm5719-llvm-ca671b0e5144910731d9ff266a60c8b37dfee8b1.zip
||/&& do not do UAC's either. This silences a bogus warning on #if -1 || 4U.
llvm-svn: 50632
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PPExpressions.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index aea203f9df9..9fda8b08624 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud