Add warnings (normally fatal) on use of archaic C features
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 11 Apr 2013 10:53:41 +0000 (11:53 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 12 Apr 2013 11:20:47 +0000 (12:20 +0100)
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

index b383c78..69dc010 100644 (file)
@@ -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"