[RFC] -Wredundant-decls: keep it or remove it?
Craig Rodrigues
rodrigc at crodrigues.org
Sat Aug 27 23:51:45 GMT 2005
On Tue, Aug 09, 2005 at 08:23:08PM -0700, David O'Brien wrote:
> On Tue, Aug 09, 2005 at 08:53:23PM -0400, Craig Rodrigues wrote:
> > It is illegal in ISO C to declare a struct as extern (implying external
> > linkage) , and then declare it as static (implying internal linkage).
> ..
> > OPTION 2:
> > Forward declare routedomain as static, but remove -Wredundant-decls
> > from kernel makefiles:
> > static struct domain routedomain;
> > ....
> > static struct domain routedomain = { ..... }
> >
> > For OPTION 2, it is necessary to remove -Wredundant-decls
> > because you will get a new compiler warning:
> >
> > warning: redundant redeclaration of 'routedomain'
> > warnig: previous declaration was here ...
>
> This is a GCC bug that I am working to get fixed.
Hi,
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;
--
Craig Rodrigues
rodrigc at crodrigues.org
More information about the freebsd-arch
mailing list