[cfe-commits] r50635 - in /cfe/trunk: lib/Lex/PPExpressions.cpp test/Preprocessor/expr_liveness.c

Chris Lattner sabre at nondot.org
Sun May 4 21:10:52 PDT 2008


Author: lattner
Date: Sun May  4 23:10:51 2008
New Revision: 50635

URL: http://llvm.org/viewvc/llvm-project?rev=50635&view=rev
Log:
fix a bug handling right associative operators that Neil noticed, hopefully
the final part of PR2279

Modified:
    cfe/trunk/lib/Lex/PPExpressions.cpp
    cfe/trunk/test/Preprocessor/expr_liveness.c

Modified: cfe/trunk/lib/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=50635&r1=50634&r2=50635&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPExpressions.cpp (original)
+++ cfe/trunk/lib/Lex/PPExpressions.cpp Sun May  4 23:10:51 2008
@@ -294,19 +294,8 @@
 /// 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 @@
     // 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());
     }

Modified: cfe/trunk/test/Preprocessor/expr_liveness.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/expr_liveness.c?rev=50635&r1=50634&r2=50635&view=diff

==============================================================================
--- cfe/trunk/test/Preprocessor/expr_liveness.c (original)
+++ cfe/trunk/test/Preprocessor/expr_liveness.c Sun May  4 23:10:51 2008
@@ -26,6 +26,9 @@
 #error
 #endif
 
+// PR2279
+#if 1 ? 2 ? 3 : 4 : 5
+#endif
 
 #else
 





More information about the cfe-commits mailing list