summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-05-05 04:10:51 +0000
committerChris Lattner <sabre@nondot.org>2008-05-05 04:10:51 +0000
commit3c57f7ebab610ee09a95fa3665c68d217b733ff6 (patch)
tree70e7d4348cfab7a11eecbb4f4a7c558b4e09a40e /clang/lib/Lex
parentbcde17222280cc15c78903389a7f5a5eee31c0ec (diff)
downloadbcm5719-llvm-3c57f7ebab610ee09a95fa3665c68d217b733ff6.tar.gz
bcm5719-llvm-3c57f7ebab610ee09a95fa3665c68d217b733ff6.zip
fix a bug handling right associative operators that Neil noticed, hopefully
the final part of PR2279 llvm-svn: 50635
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PPExpressions.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 9fda8b08624..ff0578067cf 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -294,19 +294,8 @@ static bool EvaluateValue(llvm::APSInt &Result, Token &PeekTok,
/// getPrecedence - Return the precedence of the specified binary operator
/// token. This returns:
/// ~0 - Invalid token.
-/// 14 - *,/,%
-/// 13 - -,+
-/// 12 - <<,>>
-/// 11 - >=, <=, >, <
-/// 10 - ==, !=
-/// 9 - &
-/// 8 - ^
-/// 7 - |
-/// 6 - &&
-/// 5 - ||
-/// 4 - ?
-/// 3 - :
-/// 0 - eom, )
+/// 14 -> 3 - various operators.
+/// 0 - 'eom' or ')'
static unsigned getPrecedence(tok::TokenKind Kind) {
switch (Kind) {
default: return ~0U;
@@ -402,7 +391,8 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec,
// more tightly with RHS than we do, evaluate it completely first.
if (ThisPrec < PeekPrec ||
(ThisPrec == PeekPrec && isRightAssoc)) {
- if (EvaluateDirectiveSubExpr(RHS, ThisPrec+1, PeekTok, RHSIsLive, PP))
+ if (EvaluateDirectiveSubExpr(RHS, ThisPrec+!isRightAssoc,
+ PeekTok, RHSIsLive, PP))
return true;
PeekPrec = getPrecedence(PeekTok.getKind());
}
OpenPOWER on IntegriCloud