[configure.in] Cache WARN_UNUSED_RESULT test results

This commit is contained in:
Behdad Esfahbod 2008-09-01 23:28:39 -04:00
parent ac24642614
commit 004012f1bc

View file

@ -886,23 +886,26 @@ AC_CACHE_CHECK([for supported warning flags], cairo_cv_warn_cflags, [
cairo_cv_warn_cflags=$WARN_CFLAGS
cairo_cv_warn_maybe=$MAYBE_WARN
AC_MSG_CHECKING([which warning flags were supported])])
AC_MSG_CHECKING([which warning flags were supported])
])
WARN_CFLAGS="$cairo_cv_warn_cflags"
CAIRO_CFLAGS="$CAIRO_CFLAGS $WARN_CFLAGS"
# We only wish to enable attribute(warn_unused_result) if we can prevent
# gcc from generating thousands of warnings about the misapplication of the
# attribute to void functions and variables.
AC_MSG_CHECKING([how to enable unused result warnings])
warn_unused_result=""
if echo $WARN_CFLAGS | grep -e '-Wno-attributes' >/dev/null; then
AC_TRY_COMPILE([__attribute__((__warn_unused_result__))
int f (int i) { return i; }], [],
[warn_unused_result="__attribute__((__warn_unused_result__))"])
fi
AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$warn_unused_result],
AC_CACHE_CHECK([how to enable unused result warnings], cairo_cv_warn_unused_result, [
cairo_cv_warn_unused_result=""
if echo $WARN_CFLAGS | grep -e '-Wno-attributes' >/dev/null; then
AC_TRY_COMPILE([__attribute__((__warn_unused_result__))
int f (int i) { return i; }], [],
[cairo_cv_warn_unused_result="__attribute__((__warn_unused_result__))"])
fi
])
AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$cairo_cv_warn_unused_result],
[Define to the value your compiler uses to support the warn-unused-result attribute])
AC_MSG_RESULT([$warn_unused_result])
dnl ===========================================================================
AC_SUBST(CAIRO_REQUIRES)
AC_SUBST(CAIRO_NONPKGCONFIG_CFLAGS)