[Python-checkins] cpython: disable unused result warnings when possible

benjamin.peterson python-checkins at python.org
Fri Sep 23 19:23:31 CEST 2011


http://hg.python.org/cpython/rev/e5dade9bf96f
changeset:   72455:e5dade9bf96f
user:        Benjamin Peterson <benjamin at python.org>
date:        Fri Sep 23 13:23:22 2011 -0400
summary:
  disable unused result warnings when possible

files:
  configure    |  43 ++++++++++++++++++++++++++++++++++++++++
  configure.in |  22 ++++++++++++++++++++
  2 files changed, 65 insertions(+), 0 deletions(-)


diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -5561,6 +5561,49 @@
       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
     fi
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can turn off $CC unused result warning" >&5
+$as_echo_n "checking if we can turn off $CC unused result warning... " >&6; }
+     ac_save_cc="$CC"
+     CC="$CC -Wunused-result -Werror"
+     save_CFLAGS="$CFLAGS"
+     if ${ac_cv_disable_unused_result_warning+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+           ac_cv_disable_unused_result_warning=yes
+
+else
+
+           ac_cv_disable_unused_result_warning=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+     CFLAGS="$save_CFLAGS"
+     CC="$ac_save_cc"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_disable_unused_result_warning" >&5
+$as_echo "$ac_cv_disable_unused_result_warning" >&6; }
+
+    if test $ac_cv_disable_unused_result_warning = yes
+    then
+      BASECFLAGS="$BASECFLAGS -Wno-unused-result"
+    fi
+
     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
     # support.  Without this, treatment of subnormals doesn't follow
     # the standard.
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -981,6 +981,28 @@
       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
     fi
 
+    AC_MSG_CHECKING(if we can turn off $CC unused result warning)
+     ac_save_cc="$CC"
+     CC="$CC -Wunused-result -Werror"
+     save_CFLAGS="$CFLAGS"
+     AC_CACHE_VAL(ac_cv_disable_unused_result_warning,
+       AC_COMPILE_IFELSE(
+         [
+	   AC_LANG_PROGRAM([[]], [[]])
+	 ],[
+           ac_cv_disable_unused_result_warning=yes
+	 ],[
+           ac_cv_disable_unused_result_warning=no
+	 ]))
+     CFLAGS="$save_CFLAGS"
+     CC="$ac_save_cc"
+    AC_MSG_RESULT($ac_cv_disable_unused_result_warning)
+
+    if test $ac_cv_disable_unused_result_warning = yes
+    then
+      BASECFLAGS="$BASECFLAGS -Wno-unused-result"
+    fi
+
     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
     # support.  Without this, treatment of subnormals doesn't follow
     # the standard.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list