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

Chris Lattner sabre at nondot.org
Sun May 4 00:15:21 PDT 2008


Author: lattner
Date: Sun May  4 02:15:21 2008
New Revision: 50617

URL: http://llvm.org/viewvc/llvm-project?rev=50617&view=rev
Log:
fix a nasty bug that Neil identifier in pp-expr parsing (this is PR2279 part D).

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=50617&r1=50616&r2=50617&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPExpressions.cpp (original)
+++ cfe/trunk/lib/Lex/PPExpressions.cpp Sun May  4 02:15:21 2008
@@ -433,20 +433,28 @@
     default: assert(0 && "Unknown operator token!");
     case tok::percent:
       if (RHS == 0) {
-        if (ValueLive) PP.Diag(OpToken, diag::err_pp_remainder_by_zero);
-        return true;
+        if (ValueLive) {
+          PP.Diag(OpToken, diag::err_pp_remainder_by_zero);
+          return true;
+        }
+      } else {
+        Res = LHS % RHS;
       }
-      Res = LHS % RHS;
       break;
     case tok::slash:
       if (RHS == 0) {
-        if (ValueLive) PP.Diag(OpToken, diag::err_pp_division_by_zero);
-        return true;
+        if (ValueLive) {
+          PP.Diag(OpToken, diag::err_pp_division_by_zero);
+          return true;
+        }
+        break;
       }
+
       Res = LHS / RHS;
       if (LHS.isSigned())
         Overflow = LHS.isMinSignedValue() && RHS.isAllOnesValue(); // MININT/-1
       break;
+        
     case tok::star:
       Res = LHS * RHS;
       if (LHS != 0 && RHS != 0)

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

==============================================================================
--- cfe/trunk/test/Preprocessor/expr_liveness.c (original)
+++ cfe/trunk/test/Preprocessor/expr_liveness.c Sun May  4 02:15:21 2008
@@ -20,6 +20,13 @@
 #if 0 ? 124/0 : 42
 #endif
 
+// PR2279
+#if 0 ? 1/0: 2
+#else
+#error
+#endif
+
+
 #else
 
 





More information about the cfe-commits mailing list