summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-05-20 08:22:04 -0700
committerBenjamin Peterson <benjamin@python.org>2013-05-20 08:22:04 -0700
commit3a038e80e4f8da626393fb4e71b43f9244d95629 (patch)
tree10687eb5cb50251360b3e9c916ceb24f7867cdf7 /configure.ac
parent572cc354515e81b37f0e01d31af83637ef3868f0 (diff)
downloadcpython-3a038e80e4f8da626393fb4e71b43f9244d95629.tar.gz
test that the compiler support -Werror=statement-after-declaration before using it
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac24
1 files changed, 22 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 647de88600..c9f54ddf47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1127,8 +1127,6 @@ AC_SUBST(UNIVERSAL_ARCH_FLAGS)
# tweak BASECFLAGS based on compiler and platform
case $GCC in
yes)
- BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
-
# Python doesn't violate C99 aliasing rules, but older versions of
# GCC produce warnings for legal Python code. Enable
# -fno-strict-aliasing on versions of GCC that support but produce
@@ -1186,6 +1184,28 @@ yes)
BASECFLAGS="$BASECFLAGS -Wno-unused-result"
fi
+ AC_MSG_CHECKING(for -Werror=declaration-after-statement)
+ ac_save_cc="$CC"
+ CC="$CC -Werror=declaration-after-statement"
+ save_CFLAGS="$CFLAGS"
+ AC_CACHE_VAL(ac_cv_declaration_after_statement_warning,
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM([[]], [[]])
+ ],[
+ ac_cv_declaration_after_statement_warning=yes
+ ],[
+ ac_cv_declaration_after_statement_warning=no
+ ]))
+ CFLAGS="$save_CFLAGS"
+ CC="$ac_save_cc"
+ AC_MSG_RESULT($ac_cv_declaration_after_statement_warning)
+
+ if test $ac_cv_declaration_after_statement_warning = yes
+ then
+ BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
+ 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.