From: Daniel Jacobowitz Date: Thu, 4 Jan 2007 19:42:10 +0000 (+0000) Subject: * configure.ac (build_warnings): Use -Wall and X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa79a185c9f822e4cd4a5bd773587013ea1e34bd;p=binutils-gdb.git * configure.ac (build_warnings): Use -Wall and -Wdeclaration-after-statement. * configure: Regenerated. * gdbint.texinfo (Compiler Warnings): Update for -Wall use. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c884c96c890..96edccd1aa6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2007-01-04 Daniel Jacobowitz + + * configure.ac (build_warnings): Use -Wall and + -Wdeclaration-after-statement. + * configure: Regenerated. + 2007-01-04 Vladimir Prus Simplify access to variours properties of child diff --git a/gdb/configure b/gdb/configure index c2199f9d51c..7d4f298d021 100755 --- a/gdb/configure +++ b/gdb/configure @@ -21114,32 +21114,15 @@ if test "${ERROR_ON_WARNING}" = yes ; then WERROR_CFLAGS="-Werror" fi -# NOTE: Don't add -Wall or -Wunused, they both include -# -Wunused-parameter which reports bogus warnings. -# NOTE: If you add to this list, remember to update +# The entries after -Wno-pointer-sign are disabled warnings which may +# be enabled in the future, which can not currently be used to build +# GDB. +# NOTE: If you change this list, remember to update # gdb/doc/gdbint.texinfo. -build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \ --Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral \ --Wunused-label -Wunused-function -Wno-pointer-sign" - -# GCC supports -Wuninitialized only with -O or -On, n != 0. -if test x${CFLAGS+set} = xset; then - case "${CFLAGS}" in - *"-O0"* ) ;; - *"-O"* ) - build_warnings="${build_warnings} -Wuninitialized" - ;; - esac -else - build_warnings="${build_warnings} -Wuninitialized" -fi +build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ +-Wformat-nonliteral -Wno-pointer-sign \ +-Wno-unused -Wno-switch" -# Up for debate: -Wswitch -Wcomment -trigraphs -Wtrigraphs -# -Wunused-function -Wunused-variable -Wunused-value -# -Wchar-subscripts -Wtraditional -Wshadow -Wcast-qual -# -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -# -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -# -Woverloaded-virtual -Winline -Werror" # Check whether --enable-build-warnings or --disable-build-warnings was given. if test "${enable_build_warnings+set}" = set; then enableval="$enable_build_warnings" @@ -21230,8 +21213,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$saved_CFLAGS" esac done - echo "$as_me:$LINENO: result: ${WARN_CFLAGS}${WERROR_CFLAGS}" >&5 -echo "${ECHO_T}${WARN_CFLAGS}${WERROR_CFLAGS}" >&6 + echo "$as_me:$LINENO: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5 +echo "${ECHO_T}${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6 fi diff --git a/gdb/configure.ac b/gdb/configure.ac index 0f6a1c91b5f..7a6bd80b6f6 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1138,32 +1138,15 @@ if test "${ERROR_ON_WARNING}" = yes ; then WERROR_CFLAGS="-Werror" fi -# NOTE: Don't add -Wall or -Wunused, they both include -# -Wunused-parameter which reports bogus warnings. -# NOTE: If you add to this list, remember to update +# The entries after -Wno-pointer-sign are disabled warnings which may +# be enabled in the future, which can not currently be used to build +# GDB. +# NOTE: If you change this list, remember to update # gdb/doc/gdbint.texinfo. -build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \ --Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral \ --Wunused-label -Wunused-function -Wno-pointer-sign" - -# GCC supports -Wuninitialized only with -O or -On, n != 0. -if test x${CFLAGS+set} = xset; then - case "${CFLAGS}" in - *"-O0"* ) ;; - *"-O"* ) - build_warnings="${build_warnings} -Wuninitialized" - ;; - esac -else - build_warnings="${build_warnings} -Wuninitialized" -fi +build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ +-Wformat-nonliteral -Wno-pointer-sign \ +-Wno-unused -Wno-switch" -# Up for debate: -Wswitch -Wcomment -trigraphs -Wtrigraphs -# -Wunused-function -Wunused-variable -Wunused-value -# -Wchar-subscripts -Wtraditional -Wshadow -Wcast-qual -# -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes -# -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -# -Woverloaded-virtual -Winline -Werror" AC_ARG_ENABLE(build-warnings, [ --enable-build-warnings Enable build-time compiler warnings if gcc is used], [case "${enableval}" in @@ -1208,7 +1191,7 @@ then CFLAGS="$saved_CFLAGS" esac done - AC_MSG_RESULT(${WARN_CFLAGS}${WERROR_CFLAGS}) + AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS}) fi AC_SUBST(WARN_CFLAGS) AC_SUBST(WERROR_CFLAGS) diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index df32bc67cab..7893d659a6e 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2007-01-04 Daniel Jacobowitz + + * gdbint.texinfo (Compiler Warnings): Update for -Wall use. + 2007-01-01 Joel Brobecker * gdbint.texinfo (Start of New Year Procedure): Add missing item. diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 1565f24325b..cc4d591cf29 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -5471,64 +5471,35 @@ errors.} @subsection Compiler Warnings @cindex compiler warnings -With few exceptions, developers should include the configuration option -@samp{--enable-gdb-build-warnings=,-Werror} when building @value{GDBN}. -The exceptions are listed in the file @file{gdb/MAINTAINERS}. +With few exceptions, developers should avoid the configuration option +@samp{--disable-werror} when building @value{GDBN}. The exceptions +are listed in the file @file{gdb/MAINTAINERS}. The default, when +building with @sc{gcc}, is @samp{--enable-werror}. This option causes @value{GDBN} (when built using GCC) to be compiled with a carefully selected list of compiler warning flags. Any warnings -from those flags being treated as errors. +from those flags are treated as errors. The current list of warning flags includes: @table @samp -@item -Wimplicit -Since @value{GDBN} coding standard requires all functions to be declared -using a prototype, the flag has the side effect of ensuring that -prototyped functions are always visible with out resorting to -@samp{-Wstrict-prototypes}. +@item -Wall +Recommended @sc{gcc} warnings. -@item -Wreturn-type -Such code often appears to work except on instruction set architectures -that use register windows. +@item -Wdeclaration-after-statement -@item -Wcomment +@sc{gcc} 3.x (and later) and @sc{c99} allow declarations mixed with +code, but @sc{gcc} 2.x and @sc{c89} do not. -@item -Wtrigraphs +@item -Wpointer-arith -@item -Wformat -@itemx -Wformat-nonliteral +@item -Wformat-nonliteral +Non-literal format strings, with a few exceptions, are bugs - they +might contain unintented user-supplied format specifiers. Since @value{GDBN} uses the @code{format printf} attribute on all -@code{printf} like functions these check not just @code{printf} calls +@code{printf} like functions this checks not just @code{printf} calls but also calls to functions such as @code{fprintf_unfiltered}. -@item -Wparentheses -This warning includes uses of the assignment operator within an -@code{if} statement. - -@item -Wpointer-arith - -@item -Wuninitialized - -@item -Wunused-label -This warning has the additional benefit of detecting the absence of the -@code{case} reserved word in a switch statement: -@smallexample -enum @{ FD_SCHEDULED, NOTHING_SCHEDULED @} sched; -@dots{} -switch (sched) - @{ - case FD_SCHEDULED: - @dots{}; - break; - NOTHING_SCHEDULED: - @dots{}; - break; - @} -@end smallexample - -@item -Wunused-function - @item -Wno-pointer-sign In version 4.0, GCC began warning about pointer argument passing or assignment even when the source and destination differed only in @@ -5537,19 +5508,19 @@ carefully between @code{char} and @code{unsigned char}. In early 2006 the @value{GDBN} developers decided correcting these warnings wasn't worth the time it would take. -@end table - -@emph{Pragmatics: Due to the way that @value{GDBN} is implemented most -functions have unused parameters. Consequently the warning -@samp{-Wunused-parameter} is precluded from the list. The macro +@item -Wno-unused-parameter +Due to the way that @value{GDBN} is implemented many functions have +unused parameters. Consequently this warning is avoided. The macro @code{ATTRIBUTE_UNUSED} is not used as it leads to false negatives --- it is not an error to have @code{ATTRIBUTE_UNUSED} on a parameter that -is being used. The options @samp{-Wall} and @samp{-Wunused} are also -precluded because they both include @samp{-Wunused-parameter}.} +is being used. + +@item -Wno-unused +@itemx -Wno-switch +These are warnings which might be useful for @value{GDBN}, but are +currently too noisy to enable with @samp{-Werror}. -@emph{Pragmatics: @value{GDBN} has not simply accepted the warnings -enabled by @samp{-Wall -Werror -W...}. Instead it is selecting warnings -when and where their benefits can be demonstrated.} +@end table @subsection Formatting