From f8e675148461c9eeb637ab20b46bf72a61199d5e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 22 May 2011 18:21:03 +0200 Subject: [PATCH] isl_dim.c: avoid warnings about unhandled enumeration value in switch Signed-off-by: Sven Verdoolaege --- isl_dim.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/isl_dim.c b/isl_dim.c index db595704..5a5a821c 100644 --- a/isl_dim.c +++ b/isl_dim.c @@ -509,13 +509,27 @@ struct isl_dim *isl_dim_add(struct isl_dim *dim, enum isl_dim_type type, case isl_dim_out: return isl_dim_extend(dim, dim->nparam, dim->n_in, dim->n_out + n); + default: + isl_die(dim->ctx, isl_error_invalid, + "cannot add dimensions of specified type", goto error); } - return dim; error: isl_dim_free(dim); return NULL; } +static int valid_dim_type(enum isl_dim_type type) +{ + switch (type) { + case isl_dim_param: + case isl_dim_in: + case isl_dim_out: + return 1; + default: + return 0; + } +} + __isl_give isl_dim *isl_dim_insert(__isl_take isl_dim *dim, enum isl_dim_type type, unsigned pos, unsigned n) { @@ -526,6 +540,11 @@ __isl_give isl_dim *isl_dim_insert(__isl_take isl_dim *dim, if (n == 0) return isl_dim_reset(dim, type); + if (!valid_dim_type(type)) + isl_die(dim->ctx, isl_error_invalid, + "cannot insert dimensions of specified type", + goto error); + isl_assert(dim->ctx, pos <= isl_dim_size(dim, type), goto error); dim = isl_dim_cow(dim); @@ -564,6 +583,7 @@ __isl_give isl_dim *isl_dim_insert(__isl_take isl_dim *dim, case isl_dim_param: dim->nparam += n; break; case isl_dim_in: dim->n_in += n; break; case isl_dim_out: dim->n_out += n; break; + default: ; } dim = isl_dim_reset(dim, type); @@ -642,12 +662,14 @@ __isl_give isl_dim *isl_dim_move(__isl_take isl_dim *dim, case isl_dim_param: dim->nparam += n; break; case isl_dim_in: dim->n_in += n; break; case isl_dim_out: dim->n_out += n; break; + default: ; } switch (src_type) { case isl_dim_param: dim->nparam -= n; break; case isl_dim_in: dim->n_in -= n; break; case isl_dim_out: dim->n_out -= n; break; + default: ; } if (dst_type != isl_dim_param && src_type != isl_dim_param) @@ -873,6 +895,10 @@ struct isl_dim *isl_dim_drop(struct isl_dim *dim, enum isl_dim_type type, if (num == 0) return isl_dim_reset(dim, type); + if (!valid_dim_type(type)) + isl_die(dim->ctx, isl_error_invalid, + "cannot drop dimensions of specified type", goto error); + isl_assert(dim->ctx, first + num <= n(dim, type), goto error); dim = isl_dim_cow(dim); if (!dim) @@ -892,7 +918,7 @@ struct isl_dim *isl_dim_drop(struct isl_dim *dim, enum isl_dim_type type, case isl_dim_in: get_names(dim, isl_dim_out, 0, dim->n_out, dim->names + offset(dim, isl_dim_out) - num); - case isl_dim_out: + default: ; } dim->n_name -= num; @@ -901,6 +927,7 @@ struct isl_dim *isl_dim_drop(struct isl_dim *dim, enum isl_dim_type type, case isl_dim_param: dim->nparam -= num; break; case isl_dim_in: dim->n_in -= num; break; case isl_dim_out: dim->n_out -= num; break; + default: ; } dim = isl_dim_reset(dim, type); if (type == isl_dim_param) { -- 2.11.4.GIT