[folks] Add warnings (normally fatal) on use of archaic C features



commit 43155c19ebbd06be0538926ca8eb4a33214395a7
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Thu Apr 11 11:53:41 2013 +0100

    Add warnings (normally fatal) on use of archaic C features
    
    We don't want these even in C code generated by Vala, and certainly not
    in hand-written C code.
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=697354
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Reviewed-by: Philip Withnall <philip tecnocode co uk>

 configure.ac |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b383c78..69dc010 100644
--- a/configure.ac
+++ b/configure.ac
@@ -441,6 +441,32 @@ AC_DEFINE(GLIB_DISABLE_DEPRECATION_WARNINGS, 1, [Build with GLib deprecated])
 
 ERROR_CFLAGS=
 
+AC_ARG_ENABLE([fatal-warnings],
+              AS_HELP_STRING([--disable-fatal-warnings],
+                             [Make various warnings non-fatal]),
+              [enable_fatal_warnings=$enableval], [enable_fatal_warnings=yes])
+
+AC_DEFUN([FOLKS_ADD_WARNING],
+  [
+    AS_COMPILER_FLAG([-Werror=$2],
+      [
+        AS_IF([test "x$enable_fatal_warnings" = xyes],
+          [$1="[$]$1 -Werror=$2"],
+         [$1="[$]$1 -W$2"])
+      ])
+  ])
+
+# It isn't 1970 any more. Require that we write proper ISO C with declarations,
+# avoiding hard-to-trace bugs on platforms where sizeof(int) != sizeof(void *).
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [implicit])
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [missing-declarations])
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [missing-parameter-type])
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [missing-prototypes])
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [nested-externs])
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [old-style-declaration])
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [old-style-definition])
+FOLKS_ADD_WARNING([ERROR_CFLAGS], [strict-prototypes])
+
 AS_COMPILER_FLAG([-Wall], [C_ERROR_CFLAGS="-Wall"], [C_ERROR_CFLAGS=""])
 AS_COMPILER_FLAG([-Werror], [werror=yes], [werror=no])
 
@@ -536,10 +562,6 @@ AC_SUBST([CODE_COVERAGE_CFLAGS])
 AC_SUBST([CODE_COVERAGE_LDFLAGS])
 
 # Vala-related flags
-AC_ARG_ENABLE([fatal-warnings],
-              AS_HELP_STRING([--disable-fatal-warnings],
-                             [Make warnings from valac and g-ir-scanner non-fatal]),
-              [enable_fatal_warnings=$enableval], [enable_fatal_warnings=yes])
 AS_IF([test "x$enable_vala" = "xyes" && test "x$enable_fatal_warnings" = "xyes"],
       [ERROR_INTROSPECTION_SCANNER_ARGS="\
                         $ERROR_INTROSPECTION_SCANNER_ARGS --warn-error"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]