mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
build: avoid -Wno-format on new-enough gcc
Commitc579d6b
added a sledgehammer to silence spurious warnings from gcc 4.2, but in the process, it also silenced useful warnings from gcc 4.3 through 4.5. As a result, a bug slipped in to commit0caccb58
. Tested with FreeBSD (gcc 4.2.1), RHEL 6.3 (gcc 4.4), and F17 (gcc 4.7.2), where the former didn't trip on spurious warnings, and where the latter two detected a revert of2b804cf
. * m4/virt-compile-warnings.m4 (-Wno-format): Probe for the actual spurious message, to once again allow gcc 4.4 to use -Wformat.
This commit is contained in:
parent
2b804cfafc
commit
814a8deaa1
@ -60,6 +60,23 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
|
|||||||
# gcc 4.4.6 complains this is C++ only; gcc 4.7.0 implies this from -Wall
|
# gcc 4.4.6 complains this is C++ only; gcc 4.7.0 implies this from -Wall
|
||||||
dontwarn="$dontwarn -Wenum-compare"
|
dontwarn="$dontwarn -Wenum-compare"
|
||||||
|
|
||||||
|
# gcc 4.2 treats attribute(format) as an implicit attribute(nonnull),
|
||||||
|
# which triggers spurious warnings for our usage
|
||||||
|
AC_CACHE_CHECK([whether gcc -Wformat allows NULL strings],
|
||||||
|
[lv_cv_gcc_wformat_null_works], [
|
||||||
|
save_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS='-Wunknown-pragmas -Werror -Wformat'
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||||
|
#include <stddef.h>
|
||||||
|
static __attribute__ ((__format__ (__printf__, 1, 2))) int
|
||||||
|
foo (const char *fmt, ...) { return !fmt; }
|
||||||
|
]], [[
|
||||||
|
return foo(NULL);
|
||||||
|
]])],
|
||||||
|
[lv_cv_gcc_wformat_null_works=yes],
|
||||||
|
[lv_cv_gcc_wformat_null_works=no])
|
||||||
|
CFLAGS=$save_CFLAGS])
|
||||||
|
|
||||||
# Gnulib uses '#pragma GCC diagnostic push' to silence some
|
# Gnulib uses '#pragma GCC diagnostic push' to silence some
|
||||||
# warnings, but older gcc doesn't support this.
|
# warnings, but older gcc doesn't support this.
|
||||||
AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
|
AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
|
||||||
@ -117,7 +134,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
|
|||||||
# ATTRIBUTE_FMT_PRINT, which causes -Wformat failure on our
|
# ATTRIBUTE_FMT_PRINT, which causes -Wformat failure on our
|
||||||
# intentional use of virReportError(code, NULL).
|
# intentional use of virReportError(code, NULL).
|
||||||
gl_WARN_ADD([-Wno-format-nonliteral])
|
gl_WARN_ADD([-Wno-format-nonliteral])
|
||||||
if test $lv_cv_gcc_pragma_push_works = no; then
|
if test $lv_cv_gcc_wformat_null_works = no; then
|
||||||
gl_WARN_ADD([-Wno-format])
|
gl_WARN_ADD([-Wno-format])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user