From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23312 invoked by alias); 3 Jan 2007 19:12:42 -0000 Received: (qmail 23302 invoked by uid 22791); 3 Jan 2007 19:12:40 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Wed, 03 Jan 2007 19:12:27 +0000 Received: from drow by nevyn.them.org with local (Exim 4.63) (envelope-from ) id 1H2BXF-0005XH-5n; Wed, 03 Jan 2007 14:12:25 -0500 Date: Wed, 03 Jan 2007 19:12:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii , gdb-patches@sourceware.org Subject: Re: RFC: Use -Wall -Wextra Message-ID: <20070103191225.GH17935@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , gdb-patches@sourceware.org References: <20061228195533.GA18492@nevyn.them.org> <20061229135814.GA9741@nevyn.them.org> <20061229210206.GA23681@nevyn.them.org> <20061230160034.GE15107@nevyn.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20061230160034.GE15107@nevyn.them.org> User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00074.txt.bz2 On Sat, Dec 30, 2006 at 11:00:34AM -0500, Daniel Jacobowitz wrote: > Anyway, let's go with -Wall; that's still an improvement over the > present state and fixes the annoying -Wuninitialized warnings. I'll > commit my saved up warning fixes, and then post a patch to do this. Here's what I have just tested on x86_64-pc-linux-gnu. This is a much more conservative patch than my previous one. It may still break other targets, especially native ones, with -Werror; I'll be happy to help fix any breakage if the fixes aren't apparent. OK to commit? -- Daniel Jacobowitz CodeSourcery 2007-01-03 Daniel Jacobowitz * configure.ac (build_warnings): Use -Wall and -Wdeclaration-after-statement. * configure: Regenerated. 2007-01-03 Daniel Jacobowitz * doc/gdbint.texinfo (Compiler Warnings): Update for -Wall use. Index: configure.ac =================================================================== RCS file: /cvs/src/src/gdb/configure.ac,v retrieving revision 1.37 diff -u -p -r1.37 configure.ac --- configure.ac 31 Dec 2006 20:20:13 -0000 1.37 +++ configure.ac 3 Jan 2007 19:09:53 -0000 @@ -1138,32 +1138,15 @@ if test "${ERROR_ON_WARNING}" = yes ; th 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) Index: doc/gdbint.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v retrieving revision 1.248 diff -u -p -r1.248 gdbint.texinfo --- doc/gdbint.texinfo 1 Jan 2007 14:04:18 -0000 1.248 +++ doc/gdbint.texinfo 3 Jan 2007 19:09:55 -0000 @@ -5471,63 +5471,34 @@ 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 -Wreturn-type -Such code often appears to work except on instruction set architectures -that use register windows. +@item -Wall +Recommended @sc{gcc} warnings. -@item -Wcomment +@item -Wdeclaration-after-statement -@item -Wtrigraphs - -@item -Wformat -@itemx -Wformat-nonliteral -Since @value{GDBN} uses the @code{format printf} attribute on all -@code{printf} like functions these check 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. +@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 -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 -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 this checks not just @code{printf} calls +but also calls to functions such as @code{fprintf_unfiltered}. @item -Wno-pointer-sign In version 4.0, GCC began warning about pointer argument passing or @@ -5537,19 +5508,19 @@ carefully between @code{char} and @code{ 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