]> granicus.if.org Git - clang/commitdiff
fix a nasty bug that Neil identifier in pp-expr parsing (this is PR2279 part D).
authorChris Lattner <sabre@nondot.org>
Sun, 4 May 2008 07:15:21 +0000 (07:15 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 4 May 2008 07:15:21 +0000 (07:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50617 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPExpressions.cpp
test/Preprocessor/expr_liveness.c

index 398567be367579db9728826f2daaa8700f33fb0f..631701513775554cba2edfb2ee504707c933781f 100644 (file)
@@ -433,20 +433,28 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec,
     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)
index f14ac0a9133d0ec32e51c5342cf92be8bac87275..61c073204cadf3e5e6b98249a20c9158673a0b75 100644 (file)
@@ -20,6 +20,13 @@ bar
 #if 0 ? 124/0 : 42
 #endif
 
+// PR2279
+#if 0 ? 1/0: 2
+#else
+#error
+#endif
+
+
 #else