]> granicus.if.org Git - python/commitdiff
Prohibit implicit C function declarations
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 6 Feb 2017 13:24:00 +0000 (14:24 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 6 Feb 2017 13:24:00 +0000 (14:24 +0100)
Issue #27659: use -Werror=implicit-function-declaration when possible (GCC and
Clang, but it depends on the compiler version).

Patch written by Chi Hsuan Yen.

Misc/NEWS
configure
configure.ac

index 922f4664a943bda4c9248c054a2b14f85001805e..c6402534ee9c6d9e5bf230c9e6631306b042500a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -698,6 +698,10 @@ Documentation
 Build
 -----
 
+- Issue #27659: Prohibit implicit C function declarations: use
+  -Werror=implicit-function-declaration when possible (GCC and Clang, but it
+  depends on the compiler version). Patch written by Chi Hsuan Yen.
+
 - Issue #29384: Remove old Be OS helper scripts.
 
 - Issue #26851: Set Android compilation and link flags.
index a624d1cf95413887d4163238e4d6e90d665f6bf8..1126372b0b751486501cf3004448a16d28e0caad 100755 (executable)
--- a/configure
+++ b/configure
@@ -7242,6 +7242,47 @@ fi
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_enable_unreachable_code_warning" >&5
 $as_echo "$ac_cv_enable_unreachable_code_warning" >&6; }
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can make implicit function declaration an error in $CC" >&5
+$as_echo_n "checking if we can make implicit function declaration an error in $CC... " >&6; }
+     ac_save_cc="$CC"
+     CC="$CC -Werror=implicit-function-declaration"
+     if ${ac_cv_enable_implicit_function_declaration_error+:} 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_enable_implicit_function_declaration_error=yes
+
+else
+
+           ac_cv_enable_implicit_function_declaration_error=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+     CC="$ac_save_cc"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_enable_implicit_function_declaration_error" >&5
+$as_echo "$ac_cv_enable_implicit_function_declaration_error" >&6; }
+
+    if test $ac_cv_enable_implicit_function_declaration_error = yes
+    then
+      CFLAGS_NODIST="$CFLAGS_NODIST -Werror=implicit-function-declaration"
+    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.
index 09b54a7d5f4a62af6daf4eefc3c9c21fbb69ad76..5610c5759d601a626d36b2ec54909af56027960a 100644 (file)
@@ -1689,6 +1689,26 @@ yes)
     fi
     AC_MSG_RESULT($ac_cv_enable_unreachable_code_warning)
 
+    AC_MSG_CHECKING(if we can make implicit function declaration an error in $CC)
+     ac_save_cc="$CC"
+     CC="$CC -Werror=implicit-function-declaration"
+     AC_CACHE_VAL(ac_cv_enable_implicit_function_declaration_error,
+       AC_COMPILE_IFELSE(
+         [
+          AC_LANG_PROGRAM([[]], [[]])
+        ],[
+           ac_cv_enable_implicit_function_declaration_error=yes
+        ],[
+           ac_cv_enable_implicit_function_declaration_error=no
+        ]))
+     CC="$ac_save_cc"
+    AC_MSG_RESULT($ac_cv_enable_implicit_function_declaration_error)
+
+    if test $ac_cv_enable_implicit_function_declaration_error = yes
+    then
+      CFLAGS_NODIST="$CFLAGS_NODIST -Werror=implicit-function-declaration"
+    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.