From owner-freebsd-current@FreeBSD.ORG Sun Jan 16 17:24:45 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2E9CD16A4CE; Sun, 16 Jan 2005 17:24:45 +0000 (GMT) Received: from pi.codefab.com (pi.codefab.com [199.103.21.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 94F2A43D54; Sun, 16 Jan 2005 17:24:44 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from [192.168.1.3] (pool-68-160-208-232.ny325.east.verizon.net [68.160.208.232]) by pi.codefab.com (8.12.11/8.12.11) with ESMTP id j0GHOdce043242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 16 Jan 2005 12:24:40 -0500 (EST) Message-ID: <41EAA3CD.1000903@mac.com> Date: Sun, 16 Jan 2005 12:26:37 -0500 From: Chuck Swiger Organization: The Courts of Chaos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Robert Watson References: In-Reply-To: X-Enigmail-Version: 0.90.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.9 required=5.5 tests=AWL,RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL autolearn=disabled version=3.0.1 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on pi.codefab.com cc: current@FreeBSD.org Subject: Re: gratuitous gcc warnings: unused function arguments? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Jan 2005 17:24:45 -0000 Robert Watson wrote: [ ...with regard to GCC errors like... ] > cc -O -pipe -Wsystem-headers -Werror -Wall -Wno-format-y2k -W > -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith > -Wno-uninitialized -c program.c > program.c:48: warning: unused parameter 'argv' > *** Error code 1 ...and... > cc -O -pipe -Wsystem-headers -Werror -Wall -Wno-format-y2k -W > -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith > -Wno-uninitialized -c program.c > program.c:49: warning: 'main' takes only zero or two arguments > *** Error code 1 [ ... ] > I'm not sure what is required to disable this warning, but I'd like to see > us make it optional and not keyed to lower warning levels (such as 3). Apparently, -Wunused-parameter is now being inferred from the combination of -W and -Wall. The second error message is only generated when GCC thinks it is compiling main() (or a moral equivalent thereof), so it doesn't seem likely that that error would be generated for dummyfunction(int arg1, int arg2, char *argv). However, I'll try to offer a patch which does what you've asked for and let someone else (hopefully a GCC expert/language pedant :-) second guess whether the following is a good idea: --- contrib/gcc/opts.c_orig Sun Jan 16 12:02:19 2005 +++ contrib/gcc/opts.c Sun Jan 16 12:15:23 2005 @@ -127,9 +127,6 @@ bool warn_unused_variable; bool warn_unused_value; -/* Hack for cooperation between set_Wunused and set_Wextra. */ -static bool maybe_warn_unused_parameter; - /* Type(s) of debugging information we are producing (if any). See flags.h for the definitions of the different possible types of debugging information. */ @@ -1559,7 +1556,6 @@ { extra_warnings = setting; warn_unused_value = setting; - warn_unused_parameter = (setting && maybe_warn_unused_parameter); /* We save the value of warn_uninitialized, since if they put -Wuninitialized on the command line, we need to generate a @@ -1576,13 +1572,7 @@ { warn_unused_function = setting; warn_unused_label = setting; - /* Unused function parameter warnings are reported when either - ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified. - Thus, if -Wextra has already been seen, set warn_unused_parameter; - otherwise set maybe_warn_extra_parameter, which will be picked up - by set_Wextra. */ - maybe_warn_unused_parameter = setting; - warn_unused_parameter = (setting && extra_warnings); + warn_unused_parameter = setting; warn_unused_variable = setting; warn_unused_value = setting; } --- contrib/gcc/c-decl.c_orig Sun Jan 16 11:39:32 2005 +++ contrib/gcc/c-decl.c Sun Jan 16 11:59:11 2005 @@ -5602,8 +5602,8 @@ /* It is intentional that this message does not mention the third argument because it's only mentioned in an appendix of the standard. */ - if (argct > 0 && (argct < 2 || argct > 3)) - pedwarn ("%J'%D' takes only zero or two arguments", decl1, decl1); + if (argct && (argct != 2)) + warning ("%J'%D' takes only zero or two arguments", decl1, decl1); if (! TREE_PUBLIC (decl1)) pedwarn ("%J'%D' is normally a non-static function", decl1, decl1); [ This was made on 5.3-STABLE. ] -- -Chuck