diff options
author | Chris Lattner <sabre@nondot.org> | 2008-05-05 04:10:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-05-05 04:10:51 +0000 |
commit | 9e66ba6d1c1c0e11b261e3b20ff02b999621021a (patch) | |
tree | ae9c33851dc0ad021d8b234bdc119284c063fc10 /lib/Lex/PPExpressions.cpp | |
parent | 8aedf199e986fffd4372cc9106e32f19709d7e87 (diff) |
fix a bug handling right associative operators that Neil noticed, hopefully
the final part of PR2279
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPExpressions.cpp')
-rw-r--r-- | lib/Lex/PPExpressions.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 9fda8b0862..ff0578067c 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/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()); } |