mark some functions as requiring use of return value
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 10 Oct 2009 11:19:09 +0000 (13:19 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 12 Oct 2009 20:26:24 +0000 (22:26 +0200)
Makefile.am
basis_reduction_tab.c
configure.ac
include/isl_config.h.in [moved from include/isl_libs.h.in with 54% similarity]
include/isl_ctx.h
isl_tab.c
isl_tab.h
isl_tab_pip.c
m4/ax_gcc_warn_unused_result.m4 [new file with mode: 0644]

index f60e3b9..67e85f9 100644 (file)
@@ -133,7 +133,7 @@ isl_polyhedron_detect_equalities_SOURCES = \
        polyhedron_detect_equalities.c
 
 nodist_pkginclude_HEADERS = \
-       include/isl_libs.h \
+       include/isl_config.h \
        include/isl_stdint.h
 pkginclude_HEADERS = \
        include/isl_blk.h \
index c72a836..0a4f189 100644 (file)
@@ -27,7 +27,7 @@ static void get_obj_val(struct tab_lp* lp, mpq_t *F);
 static void delete_lp(struct tab_lp *lp);
 static int add_lp_row(struct tab_lp *lp, isl_int *row, int dim);
 static void get_alpha(struct tab_lp* lp, int row, mpq_t *alpha);
-static int del_lp_row(struct tab_lp *lp);
+static int del_lp_row(struct tab_lp *lp) WARN_UNUSED;
 static int cut_lp_to_hyperplane(struct tab_lp *lp, isl_int *row);
 
 #define GBR_LP                             struct tab_lp
index e4994f4..8f5afe5 100644 (file)
@@ -8,6 +8,7 @@ versioninfo=1:0:0
 AC_PROG_CC
 
 AX_CC_MAXOPT
+AX_GCC_WARN_UNUSED_RESULT
 
 AC_PROG_LIBTOOL
 
@@ -139,7 +140,7 @@ PACKAGE_CFLAGS="-I$prefix/include/isl"
 AX_CREATE_PKGCONFIG_INFO
 
 AC_CONFIG_HEADERS(config.h)
-AC_CONFIG_HEADERS(include/isl_libs.h)
+AC_CONFIG_HEADERS(include/isl_config.h)
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_FILES(doc/Makefile)
 if test $with_piplib = bundled; then
similarity index 54%
rename from include/isl_libs.h.in
rename to include/isl_config.h.in
index 5dd5d00..69ad9ad 100644 (file)
@@ -1,2 +1,4 @@
+#undef GCC_WARN_UNUSED_RESULT
+
 #undef ISL_POLYLIB
 #undef ISL_PIPLIB
index 644b9b6..a9aea29 100644 (file)
@@ -7,12 +7,18 @@
 #include <isl_int.h>
 #include <isl_blk.h>
 #include <isl_hash.h>
-#include <isl_libs.h>
+#include <isl_config.h>
 
 #define __isl_give
 #define __isl_take
 #define __isl_keep
 
+#ifdef GCC_WARN_UNUSED_RESULT
+#define        WARN_UNUSED     GCC_WARN_UNUSED_RESULT
+#else
+#define WARN_UNUSED
+#endif
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
index b3ebc49..c09b6cb 100644 (file)
--- a/isl_tab.c
+++ b/isl_tab.c
@@ -746,6 +746,8 @@ static void swap_rows(struct isl_tab *tab, int row1, int row2)
 }
 
 static int push_union(struct isl_tab *tab,
+       enum isl_tab_undo_type type, union isl_tab_undo_val u) WARN_UNUSED;
+static int push_union(struct isl_tab *tab,
        enum isl_tab_undo_type type, union isl_tab_undo_val u)
 {
        struct isl_tab_undo *undo;
@@ -1099,6 +1101,7 @@ int isl_tab_pivot(struct isl_tab *tab, int row, int col)
  * If sgn = 0, then the variable is unbounded in both directions,
  * and we pivot with any row we can find.
  */
+static int to_row(struct isl_tab *tab, struct isl_tab_var *var, int sign) WARN_UNUSED;
 static int to_row(struct isl_tab *tab, struct isl_tab_var *var, int sign)
 {
        int r;
@@ -1448,6 +1451,7 @@ int isl_tab_kill_col(struct isl_tab *tab, int col)
  * then also be written as the negative sum of non-negative variables
  * and must therefore also be zero.
  */
+static int close_row(struct isl_tab *tab, struct isl_tab_var *var) WARN_UNUSED;
 static int close_row(struct isl_tab *tab, struct isl_tab_var *var)
 {
        int j;
@@ -1677,6 +1681,7 @@ error:
 /* Pivot a non-negative variable down until it reaches the value zero
  * and then pivot the variable into a column position.
  */
+static int to_col(struct isl_tab *tab, struct isl_tab_var *var) WARN_UNUSED;
 static int to_col(struct isl_tab *tab, struct isl_tab_var *var)
 {
        int i;
@@ -2567,6 +2572,7 @@ struct isl_tab_undo *isl_tab_snap(struct isl_tab *tab)
 
 /* Undo the operation performed by isl_tab_relax.
  */
+static int unrelax(struct isl_tab *tab, struct isl_tab_var *var) WARN_UNUSED;
 static int unrelax(struct isl_tab *tab, struct isl_tab_var *var)
 {
        unsigned off = 2 + tab->M;
@@ -2593,6 +2599,7 @@ static int unrelax(struct isl_tab *tab, struct isl_tab_var *var)
        return 0;
 }
 
+static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo) WARN_UNUSED;
 static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo)
 {
        struct isl_tab_var *var = var_from_index(tab, undo->u.var_index);
@@ -2715,6 +2722,7 @@ static void drop_samples_since(struct isl_tab *tab, int n)
        }
 }
 
+static int perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo) WARN_UNUSED;
 static int perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo)
 {
        switch (undo->type) {
index 365d54b..5036273 100644 (file)
--- a/isl_tab.h
+++ b/isl_tab.h
@@ -165,17 +165,17 @@ struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap,
        struct isl_tab *tab);
 struct isl_basic_set *isl_basic_set_update_from_tab(struct isl_basic_set *bset,
        struct isl_tab *tab);
-struct isl_tab *isl_tab_detect_implicit_equalities(struct isl_tab *tab);
-struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab);
+struct isl_tab *isl_tab_detect_implicit_equalities(struct isl_tab *tab) WARN_UNUSED;
+struct isl_tab *isl_tab_detect_redundant(struct isl_tab *tab) WARN_UNUSED;
 #define ISL_TAB_SAVE_DUAL      (1 << 0)
 enum isl_lp_result isl_tab_min(struct isl_tab *tab,
        isl_int *f, isl_int denom, isl_int *opt, isl_int *opt_denom,
-       unsigned flags);
+       unsigned flags) WARN_UNUSED;
 
-struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new);
-struct isl_tab *isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq);
-struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq);
-struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq);
+struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new) WARN_UNUSED;
+struct isl_tab *isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED;
+struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
+struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
 
 int isl_tab_is_equality(struct isl_tab *tab, int con);
 int isl_tab_is_redundant(struct isl_tab *tab, int con);
@@ -195,10 +195,10 @@ enum isl_ineq_type {
 enum isl_ineq_type isl_tab_ineq_type(struct isl_tab *tab, isl_int *ineq);
 
 struct isl_tab_undo *isl_tab_snap(struct isl_tab *tab);
-int isl_tab_rollback(struct isl_tab *tab, struct isl_tab_undo *snap);
+int isl_tab_rollback(struct isl_tab *tab, struct isl_tab_undo *snap) WARN_UNUSED;
 
-struct isl_tab *isl_tab_relax(struct isl_tab *tab, int con);
-struct isl_tab *isl_tab_select_facet(struct isl_tab *tab, int con);
+struct isl_tab *isl_tab_relax(struct isl_tab *tab, int con) WARN_UNUSED;
+struct isl_tab *isl_tab_select_facet(struct isl_tab *tab, int con) WARN_UNUSED;
 
 void isl_tab_dump(struct isl_tab *tab, FILE *out, int indent);
 
@@ -209,32 +209,32 @@ struct isl_map *isl_tab_basic_map_partial_lexopt(
 /* private */
 
 struct isl_tab_var *isl_tab_var_from_row(struct isl_tab *tab, int i);
-int isl_tab_mark_redundant(struct isl_tab *tab, int row);
+int isl_tab_mark_redundant(struct isl_tab *tab, int row) WARN_UNUSED;
 struct isl_tab *isl_tab_mark_empty(struct isl_tab *tab);
 struct isl_tab *isl_tab_dup(struct isl_tab *tab);
 struct isl_tab *isl_tab_product(struct isl_tab *tab1, struct isl_tab *tab2);
-int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new);
-int isl_tab_allocate_con(struct isl_tab *tab);
-int isl_tab_extend_vars(struct isl_tab *tab, unsigned n_new);
-int isl_tab_allocate_var(struct isl_tab *tab);
-int isl_tab_pivot(struct isl_tab *tab, int row, int col);
-int isl_tab_add_row(struct isl_tab *tab, isl_int *line);
+int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new) WARN_UNUSED;
+int isl_tab_allocate_con(struct isl_tab *tab) WARN_UNUSED;
+int isl_tab_extend_vars(struct isl_tab *tab, unsigned n_new) WARN_UNUSED;
+int isl_tab_allocate_var(struct isl_tab *tab) WARN_UNUSED;
+int isl_tab_pivot(struct isl_tab *tab, int row, int col) WARN_UNUSED;
+int isl_tab_add_row(struct isl_tab *tab, isl_int *line) WARN_UNUSED;
 int isl_tab_row_is_redundant(struct isl_tab *tab, int row);
 int isl_tab_min_at_most_neg_one(struct isl_tab *tab, struct isl_tab_var *var);
-int isl_tab_kill_col(struct isl_tab *tab, int col);
+int isl_tab_kill_col(struct isl_tab *tab, int col) WARN_UNUSED;
 
-int isl_tab_push(struct isl_tab *tab, enum isl_tab_undo_type type);
+int isl_tab_push(struct isl_tab *tab, enum isl_tab_undo_type type) WARN_UNUSED;
 int isl_tab_push_var(struct isl_tab *tab,
-       enum isl_tab_undo_type type, struct isl_tab_var *var);
-int isl_tab_push_basis(struct isl_tab *tab);
+       enum isl_tab_undo_type type, struct isl_tab_var *var) WARN_UNUSED;
+int isl_tab_push_basis(struct isl_tab *tab) WARN_UNUSED;
 
-struct isl_tab *isl_tab_init_samples(struct isl_tab *tab);
+struct isl_tab *isl_tab_init_samples(struct isl_tab *tab) WARN_UNUSED;
 struct isl_tab *isl_tab_add_sample(struct isl_tab *tab,
-       __isl_take isl_vec *sample);
+       __isl_take isl_vec *sample) WARN_UNUSED;
 struct isl_tab *isl_tab_drop_sample(struct isl_tab *tab, int s);
-int isl_tab_save_samples(struct isl_tab *tab);
+int isl_tab_save_samples(struct isl_tab *tab) WARN_UNUSED;
 
 struct isl_tab *isl_tab_detect_equalities(struct isl_tab *tab,
-       struct isl_tab *tab_cone);
+       struct isl_tab *tab_cone) WARN_UNUSED;
 
 #endif
index 9f840f0..65eaf18 100644 (file)
@@ -796,7 +796,7 @@ static int first_neg(struct isl_tab *tab)
  * smallest increment in the sample point.  If there is no such column
  * then the tableau is infeasible.
  */
-static struct isl_tab *restore_lexmin(struct isl_tab *tab);
+static struct isl_tab *restore_lexmin(struct isl_tab *tab) WARN_UNUSED;
 static struct isl_tab *restore_lexmin(struct isl_tab *tab)
 {
        int row, col;
@@ -930,6 +930,7 @@ static int is_constant(struct isl_tab *tab, int row)
  * In the end we try to use one of the two constraints to eliminate
  * a column.
  */
+static struct isl_tab *add_lexmin_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
 static struct isl_tab *add_lexmin_eq(struct isl_tab *tab, isl_int *eq)
 {
        int r1, r2;
diff --git a/m4/ax_gcc_warn_unused_result.m4 b/m4/ax_gcc_warn_unused_result.m4
new file mode 100644 (file)
index 0000000..a957f8f
--- /dev/null
@@ -0,0 +1,56 @@
+# ===========================================================================
+#    http://www.nongnu.org/autoconf-archive/ax_gcc_warn_unused_result.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_GCC_WARN_UNUSED_RESULT
+#
+# DESCRIPTION
+#
+#   The macro will compile a test program to see whether the compiler does
+#   understand the per-function postfix pragma.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AX_GCC_WARN_UNUSED_RESULT],[dnl
+AC_CACHE_CHECK(
+ [whether the compiler supports function __attribute__((__warn_unused_result__))],
+ ax_cv_gcc_warn_unused_result,[
+ AC_TRY_COMPILE([__attribute__((__warn_unused_result__))
+ int f(int i) { return i; }],
+ [],
+ ax_cv_gcc_warn_unused_result=yes, ax_cv_gcc_warn_unused_result=no)])
+ if test "$ax_cv_gcc_warn_unused_result" = yes; then
+   AC_DEFINE([GCC_WARN_UNUSED_RESULT],[__attribute__((__warn_unused_result__))],
+    [most gcc compilers know a function __attribute__((__warn_unused_result__))])
+ fi
+])