diff options
author | Jim Meyering <meyering@redhat.com> | 2011-09-12 15:04:32 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-09-12 19:07:00 +0200 |
commit | 3f456c54bbd3b32e2324363ec9356137a27f7af4 (patch) | |
tree | b91f929835816fa1b6a60df2737767318f2b1b6d | |
parent | 82e86b483184fdc2646da679700a1190915a18c0 (diff) | |
download | coreutils-3f456c54bbd3b32e2324363ec9356137a27f7af4.tar.xz |
build: avoid unwarranted failure w/gcc-4.6.1 and --enable-gcc-warnings
* configure.ac (gl_GCC_VERSION_IFELSE): Define new macro.
(WERROR_CFLAGS): With --enable-gcc-warnings, use it to
add -Wsuggest-attribute=pure only with gcc 4.7 or newer.
-rw-r--r-- | configure.ac | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 291b19e5c..aeca73fe1 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,24 @@ AC_ARG_ENABLE([gcc-warnings], [gl_gcc_warnings=no] ) +# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found]) +# ------------------------------------------------ +# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND. +# Otherwise, run RUN-IF-NOT-FOUND. +AC_DEFUN([gl_GCC_VERSION_IFELSE], + [AC_PREPROC_IFELSE( + [AC_LANG_PROGRAM( + [[ +#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__) +/* ok */ +#else +# error "your version of gcc is older than $1.$2" +#endif + ]]), + ], [$3], [$4]) + ] +) + if test "$gl_gcc_warnings" = yes; then gl_WARN_ADD([-Werror], [WERROR_CFLAGS]) AC_SUBST([WERROR_CFLAGS]) @@ -102,9 +120,15 @@ if test "$gl_gcc_warnings" = yes; then gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now gl_WARN_ADD([-Wsuggest-attribute=const]) - gl_WARN_ADD([-Wsuggest-attribute=pure]) gl_WARN_ADD([-Wsuggest-attribute=noreturn]) + # Enable this warning only with gcc-4.7 and newer. With 4.6.1 20110824, + # it suggests test.c's advance function may be pure, even though it + # increments a global variable. Oops. + # Normally we'd write code to test for the precise failure, but that + # requires a relatively large input to make gcc exhibit the failure. + gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])]) + # In spite of excluding -Wlogical-op above, it is enabled, as of # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c gl_WARN_ADD([-Wno-logical-op]) |