[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
enable -Wdeclaration-after-statement
From: |
Ben Pfaff |
Subject: |
enable -Wdeclaration-after-statement |
Date: |
Wed, 29 Mar 2006 12:09:03 -0800 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
I've noticed that recently some code has been checked in that
puts declarations after statements within a single block. C++
accepts that, and so does C99, and so does GCC with its
extensions enabled, but it's not allowed in C90. If I recall
correctly, we had to fix a few of these that crept in before the
0.4.0 release when we tested with other compilers.
Thus, I've prepared a change set to enable a warning for this.
Old GCC doesn't support the warning, so we have to check for
support.
Here's the set of changes. I also have it check for -Wshadow,
which sounds useful, and I noticed that a funny character crept
in at the beginning of configure.ac, so I deleted it.
Comments?
--- acinclude.m4.~1.5.~ 2006-03-04 13:00:55.000000000 -0800
+++ acinclude.m4 2006-03-29 11:56:46.000000000 -0800
@@ -3,6 +3,22 @@ dnl This file is free software; the Free
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
+dnl Check whether a warning flag is accepted.
+dnl If so, add it to CFLAGS.
+dnl Example: PSPP_ENABLE_WARNING(-Wdeclaration-after-statement)
+AC_DEFUN([PSPP_ENABLE_WARNING],
+[
+ m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
+ AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name],
+ [pspp_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes],
[pspp_cv_name[]=no])
+ CFLAGS="$pspp_save_CFLAGS"])
+ if test $pspp_cv_name = yes; then
+ CFLAGS="$CFLAGS $1"
+ fi
+])
+
dnl Check for readline and history libraries.
dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from
Index: configure.ac
===================================================================
RCS file: /cvsroot/pspp/pspp/configure.ac,v
retrieving revision 1.41
diff -u -p -r1.41 configure.ac
--- configure.ac 17 Mar 2006 00:41:57 -0000 1.41
+++ configure.ac 29 Mar 2006 20:07:02 -0000
@@ -1,4 +1,4 @@
-0dnl Process this file with autoconf to produce a configure script.
+dnl Process this file with autoconf to produce a configure script.
dnl Initialize.
AX_PREREQ(2.57)
@@ -13,6 +13,9 @@ AM_PROG_CC_C_O
AC_PROG_RANLIB
gl_EARLY
+PSPP_ENABLE_WARNING(-Wdeclaration-after-statement)
+PSPP_ENABLE_WARNING(-Wshadow)
+
AM_CONDITIONAL(cc_is_gcc, test x"$GCC" = x"yes" )
--
"Ho ho ho. I _so_ enjoy making a fool out of myself."
--Linus, on Christmas Day, 2000
- enable -Wdeclaration-after-statement,
Ben Pfaff <=