correctly test for -Wno-unused-result support

gcc is only giving warning for unknown -Wno-XXX flags so test never
fails on gcc even if -Wno-XXX is not supported. By using
-Wunused-result we're able to test if gcc actually supports it.

This fixes issue #703.
This commit is contained in:
Aliaksey Kandratsenka 2015-10-04 11:04:12 -07:00 committed by Aliaksey Kandratsenka
parent 7753d8239b
commit 8cc75acd1f

View File

@ -306,11 +306,16 @@ AM_CONDITIONAL(I386, test "$is_i386" = yes)
AC_CACHE_CHECK([if the compiler supports -Wno-unused-result],
perftools_cv_w_no_unused_result,
[OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wno-error -Wno-unused-result"
CFLAGS="$CFLAGS -Wno-error -Wunused-result"
# gcc doesn't warn about unknown flags unless it's
# also warning for some other purpose, hence the
# divide-by-0. (We use -Wno-error to make sure the
# divide-by-0 doesn't cause this test to fail!)
#
# Also gcc is giving only warning for unknown flags of
# -Wno-XXX form. So in order to detect support we're
# using -Wunused-result which will cause gcc to give
# error which we can detect.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, return 1/0)],
perftools_cv_w_no_unused_result=yes,
perftools_cv_w_no_unused_result=no)