This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Tue, Aug 30, 2005 at 10:23:14PM +0000, Joseph S. Myers wrote:
> As I understand this patch, it would lose both warnings for
>
> static int i;
> static int i = 1;
> static int i;
Based on help from Andrew Pinski, I modified my patch.
2005-8-31 Craig Rodrigues <rodrigc@gcc.gnu.org>
* c-decl.c (diagnose_mismatched_decls): With -Wredundant-decls,
do not issue warning for static forward declaration of static variables.
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 31 Aug 2005 04:55:40 -0000
@@ -1559,7 +1559,11 @@
&& !(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)
+ && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)))
{
warning ("%Jredundant redeclaration of %qD", newdecl, newdecl);
warned = true;
I duplicated the logic for function decls followed by a function definition
in the same if statement. I also have an attached testcase.
--
Craig Rodrigues
rodrigc@crodrigues.org
Attachment:
Wredundant-decls-2.c
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |