diff options
| author | Mark Wielaard <[email protected]> | 2016-02-09 16:10:22 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-02-15 23:45:35 +0100 |
| commit | 8bc1423bdc6f0790a669a43ce1604763a3e55587 (patch) | |
| tree | ad4440547746fac6fe138cc8f411ebde11bce053 | |
| 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 <[email protected]>
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | config/ChangeLog | 6 | ||||
| -rw-r--r-- | config/eu.am | 16 | ||||
| -rw-r--r-- | configure.ac | 22 |
4 files changed, 48 insertions, 1 deletions
@@ -1,3 +1,8 @@ +2016-02-08 Mark Wielaard <[email protected]> + + * configure.ac: Add checks for sane -Wlogical-op and whether gcc + accepts -Wduplicated-cond. + 2016-01-08 Mark Wielaard <[email protected]> * configure.ac: Set version to 0.165. diff --git a/config/ChangeLog b/config/ChangeLog index 8e20f1e6..8523cb31 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,9 @@ +2016-02-09 Mark Wielaard <[email protected]> + + * eu.am: Check SANE_LOGICAL_OP_WARNING and + HAVE_DUPLICATED_COND_WARNING. + (AM_CFLAGS): Add LOGICAL_OP_WARNING and DUPLICATED_COND_WARNING. + 2016-01-08 Mark Wielaard <[email protected]> * elfutils.spec.in: Add elfcompress. Update for 0.165. diff --git a/config/eu.am b/config/eu.am index 0095da5a..c4e9279a 100644 --- a/config/eu.am +++ b/config/eu.am @@ -1,6 +1,6 @@ ## Common automake fragments for elfutils subdirectory makefiles. ## -## Copyright (C) 2010, 2014 Red Hat, Inc. +## Copyright (C) 2010, 2014, 2016 Red Hat, Inc. ## ## This file is part of elfutils. ## @@ -42,8 +42,22 @@ STACK_USAGE_WARNING=-Wstack-usage=262144 else STACK_USAGE_WARNING= endif + +if SANE_LOGICAL_OP_WARNING +LOGICAL_OP_WARNING=-Wlogical-op +else +LOGICAL_OP_WARNING= +endif + +if HAVE_DUPLICATED_COND_WARNING +DUPLICATED_COND_WARNING=-Wduplicated-cond +else +DUPLICATED_COND_WARNING= +endif + AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ -Wold-style-definition -Wstrict-prototypes \ + $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ $(if $($(*F)_no_Werror),,-Werror) \ $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ 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( |
