[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#4434: add -Wdeclaration-after-statement to CFLAGS if supported
From: |
Dan Nicolaescu |
Subject: |
bug#4434: add -Wdeclaration-after-statement to CFLAGS if supported |
Date: |
Thu, 19 Nov 2009 08:55:34 -0800 (PST) |
Dan Nicolaescu <dann@ics.uci.edu> writes:
> Recently we've had a few instances of declarations being added in the
> middle of a block.
>
> gcc has a flag to warn about this.
>
> Here's a patch to add this flag to CFLAGS (it mirrors what we already do
> for -Wno-pointer-sign).
>
> OK to check in?
Stefan, any reason not to check this in?
I just run into compilation errors when compiling the current CVS on an
old machine that uses gcc-2.96, 3-4 files need fixing.
> Index: configure.in
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/configure.in,v
> retrieving revision 1.607
> diff -u -3 -p -u -p -r1.607 configure.in
> --- configure.in 23 Aug 2009 02:15:00 -0000 1.607
> +++ configure.in 14 Sep 2009 18:46:36 -0000
> @@ -757,6 +757,19 @@ CFLAGS="$SAVE_CFLAGS"
> unset has_option
> unset SAVE_CFLAGS
>
> +### Use -Wdeclaration-after-statement if the compiler supports it
> +AC_MSG_CHECKING([whether gcc understands
> -Wdeclaration-after-statement])
> +SAVE_CFLAGS="$CFLAGS"
> +CFLAGS="$CFLAGS -Wdeclaration-after-statement"
> +AC_TRY_COMPILE([], [], has_option=yes, has_option=no,)
> +if test $has_option = yes; then
> + C_WARNINGS_SWITCH="-Wdeclaration-after-statement $C_WARNINGS_SWITCH"
> +fi
> +AC_MSG_RESULT($has_option)
> +CFLAGS="$SAVE_CFLAGS"
> +unset has_option
> +unset SAVE_CFLAGS
> +
> #### Some other nice autoconf tests.
>
> dnl checks for programs
- bug#4434: add -Wdeclaration-after-statement to CFLAGS if supported,
Dan Nicolaescu <=