Hi,
We allow c_expr to be empty which accepts cases like the following:

(simplify
  match-operand
  (if ()
    result-operand))

(simplify
  match-operand
  {})

The attached patch rejects empty c_expr.
Ok for trunk after bootstrap + test ?

Thank you,
Prathamesh
2015-07-15  Prathamesh Kulkarni  <prathamesh.kulka...@linaro.org>

        * genmatch.c (parse_c_expr): Reject empty c_expr.
Index: genmatch.c
===================================================================
--- genmatch.c  (revision 225834)
+++ genmatch.c  (working copy)
@@ -3375,6 +3375,7 @@
   unsigned opencnt;
   vec<cpp_token> code = vNULL;
   unsigned nr_stmts = 0;
+  bool empty = true;
   eat_token (start);
   if (start == CPP_OPEN_PAREN)
     end = CPP_CLOSE_PAREN;
@@ -3394,6 +3395,7 @@
               && --opencnt == 0)
        break;
 
+      empty = false;
       /* This is a lame way of counting the number of statements.  */
       if (token->type == CPP_SEMICOLON)
        nr_stmts++;
@@ -3412,6 +3414,10 @@
       code.safe_push (*token);
     }
   while (1);
+
+  if (empty)
+    fatal_at (token, "c_expr cannot be empty");
+
   return new c_expr (r, code, nr_stmts, vNULL, capture_ids);
 }
 

Reply via email to