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]

[C PATCH] PR23228


Hi,

Scratching a personal itch.  This patch just marks the DECL node
that should be ignored according to diagnose_mismatched_decls with
TREE_NO_WARNING, so that the extra warning mentioned in the bug
audit trail is not emitted.

This is a regression from good-old 2.95.  Bootstrapped and tested
on x86_64-suse-linux-gnu.  OK for mainline?

Gr.
Steven

	PR c/23228
	* c-decl.c (pop_scope): Don't warn about an unused variable
	if it is marked with TREE_NO_WARNING.
	(duplicate_decls): Set TREE_NO_WARNING if olddecl and newdecl
	somenow mismatch and olddecl is to be replaced.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.687
diff -u -3 -p -r1.687 c-decl.c
--- c-decl.c	4 Oct 2005 13:58:41 -0000	1.687
+++ c-decl.c	12 Oct 2005 19:33:17 -0000
@@ -803,6 +803,7 @@ pop_scope (void)
 	case VAR_DECL:
 	  /* Warnings for unused variables.  */
 	  if (!TREE_USED (p)
+	      && !TREE_NO_WARNING (p)
 	      && !DECL_IN_SYSTEM_HEADER (p)
 	      && DECL_NAME (p)
 	      && !DECL_ARTIFICIAL (p)
@@ -1876,7 +1877,11 @@ duplicate_decls (tree newdecl, tree oldd
   tree newtype = NULL, oldtype = NULL;
 
   if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype))
-    return false;
+    {
+      /* Avoid `unused variable' and other warnings warnings for OLDDECL.  */
+      TREE_NO_WARNING (olddecl) = 1;
+      return false;
+    }
 
   merge_decls (newdecl, olddecl, newtype, oldtype);
   return true;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]