Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Aug 2005 17:36:01 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Craig Rodrigues <rodrigc@crodrigues.org>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: [RFC] -Wredundant-decls: keep it or remove it?
Message-ID:  <20050828172712.T86328@delplex.bde.org>
In-Reply-To: <20050827235140.GA3063@crodrigues.org>
References:  <20050810005323.GA42721@crodrigues.org> <20050810032308.GA80916@dragon.NUXI.org> <20050827235140.GA3063@crodrigues.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 27 Aug 2005, Craig Rodrigues wrote:

> On Tue, Aug 09, 2005 at 08:23:08PM -0700, David O'Brien wrote:
>> This is a GCC bug that I am working to get fixed.
>
> Did you try something like this patch to GCC?
>
> Index: c-decl.c
> ===================================================================
> RCS file: /cvsroot/gcc/gcc/gcc/c-decl.c,v
> retrieving revision 1.630.6.16
> diff -u -u -r1.630.6.16 c-decl.c
> --- c-decl.c	16 Aug 2005 20:34:19 -0000	1.630.6.16
> +++ c-decl.c	27 Aug 2005 23:43:06 -0000
> @@ -1559,7 +1559,10 @@
>       && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
>       /* Don't warn about forward parameter decls.  */
>       && !(TREE_CODE (newdecl) == PARM_DECL
> -	   && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl)))
> +	   && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
> +      /* Don't warn about forward static variable decls.  */
> +      && !(TREE_CODE (newdecl) == VAR_DECL
> +	   && !TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl)))
>     {
>       warning ("%Jredundant redeclaration of %qD", newdecl, newdecl);
>       warned = true;

It should warn about static variable decls iff they are redundant.  This
requires determining if the new declaration adds info.  I couldn't find
any macros to help determine this, not even ones to say if the new
declaration has an initializer and the old one doesn't.

Also, it shouldn't say that a redundant decl is a "redundant redeclaration".
All (identical) redeclarations are redundant, but not all redundancies are
caused by (identical) redeclarations.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050828172712.T86328>