diff options
author | Mark Wielaard <mjw@redhat.com> | 2016-02-09 16:10:22 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2016-02-15 23:45:35 +0100 |
commit | 8bc1423bdc6f0790a669a43ce1604763a3e55587 (patch) | |
tree | ad4440547746fac6fe138cc8f411ebde11bce053 /configure.ac | |
parent | f4dc76404ce8116b806550d7515ec98be953df9e (diff) |
config: Check for and use gcc -Wlogical-op and -Wduplicated-cond.
Both -Wlogical-op and -Wduplicated-cond may produce useful warnings.
But we have to check them first. Older versions of gcc had a -Wlogical-op
that warned on some constructs using macros that are not erronious.
Only GCC6 has -Wduplicated-cond.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 9a3301f5..d447db7e 100644 --- a/configure.ac +++ b/configure.ac @@ -291,6 +291,28 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], CFLAGS="$old_CFLAGS"]) AM_CONDITIONAL(ADD_STACK_USAGE_WARNING, [test "x$ac_cv_stack_usage" != "xno"]) +# -Wlogical-op was too fragile in the past, make sure we get a sane one. +AC_CACHE_CHECK([whether gcc has a sane -Wlogical-op], ac_cv_logical_op, [dnl +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wlogical-op -Werror" +AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [#define FLAG 1 + int f (int r, int f) { return (r && (FLAG || (FLAG & f))); }])], + ac_cv_logical_op=yes, ac_cv_logical_op=no) +CFLAGS="$old_CFLAGS"]) +AM_CONDITIONAL(SANE_LOGICAL_OP_WARNING, + [test "x$ac_cv_logical_op" != "xno"]) + +# -Wduplicated-cond was added by GCC6 +AC_CACHE_CHECK([whether gcc accepts -Wduplicated-cond], ac_cv_duplicated_cond, [dnl +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wduplicated-cond" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], + ac_cv_duplicated_cond=yes, ac_cv_duplicated_cond=no) +CFLAGS="$old_CFLAGS"]) +AM_CONDITIONAL(HAVE_DUPLICATED_COND_WARNING, + [test "x$ac_cv_duplicated_cond" != "xno"]) + dnl Check if we have argp available from our libc AC_LINK_IFELSE( [AC_LANG_PROGRAM( |