isl_{multi_,}union_pw_aff_read_from_str: accept empty expressions
authorSven Verdoolaege <sven@cerebras.net>
Fri, 19 Jul 2024 08:54:27 +0000 (19 10:54 +0200)
committerSven Verdoolaege <sven@cerebras.net>
Sun, 28 Jul 2024 12:54:17 +0000 (28 14:54 +0200)
Signed-off-by: Sven Verdoolaege <sven@cerebras.net>
isl_input.c
isl_test.c

index 08260cd..6686126 100644 (file)
@@ -3927,6 +3927,18 @@ static __isl_give isl_multi_pw_aff *isl_stream_read_with_params_multi_pw_aff(
 #include "isl_stream_read_with_params_templ.c"
 #include "isl_read_from_str_templ.c"
 
+/* Return an empty isl_union_pw_aff with parameter domain "dom".
+ */
+static __isl_give isl_union_pw_aff *empty_union_pw_aff_with_dom(
+       __isl_take isl_set *dom)
+{
+       isl_space *space;
+
+       space = isl_set_get_space(dom);
+       isl_set_free(dom);
+       return isl_union_pw_aff_empty_space(space);
+}
+
 /* Read the body of an isl_union_pw_aff from "s" with parameter domain "dom".
  */
 static __isl_give isl_union_pw_aff *read_union_pw_aff_with_dom(
@@ -3937,6 +3949,9 @@ static __isl_give isl_union_pw_aff *read_union_pw_aff_with_dom(
        isl_set *aff_dom;
        int n;
 
+       if (isl_stream_next_token_is(s, '}'))
+               return empty_union_pw_aff_with_dom(dom);
+
        n = v->n;
        aff_dom = read_aff_domain(s, isl_set_copy(dom), v);
        pa = read_pw_aff_with_dom(s, aff_dom, v);
index 271f876..7cd51c3 100644 (file)
@@ -294,6 +294,8 @@ static const char *reparse_multi_union_pw_aff_tests[] = {
        "A[{ S[x] -> [x + 1]; T[x] -> [x] }]",
        "(A[{ S[x] -> [x + 1]; T[x] -> [x] }] : "
                "{ S[x] : x > 0; T[y] : y >= 0 })",
+       "A[{ }]",
+       "A[{ }, { S[x] -> [x + 1]; T[x] -> [x] }]",
 };
 
 #undef BASE