Blame SOURCES/gcc32-rh181894.patch

4ac4fd
2006-08-09  Alexandre Oliva  <aoliva@redhat.com>
4ac4fd
4ac4fd
	* function.c (do_warn_unused_parameter): Do not issue warnings
4ac4fd
	for declarations in system headers.
4ac4fd
4ac4fd
2006-02-22  Alexandre Oliva  <aoliva@redhat.com>
4ac4fd
4ac4fd
	Backport and tweak:
4ac4fd
	2004-05-06  Jan Hubicka  <jh@suse.cz>
4ac4fd
	PR c/15004
4ac4fd
	* function.c (do_warn_unused_parameter): Break out form ...
4ac4fd
	(expand_function_end): ... here.
4ac4fd
	* function.h (do_warn_unused_parameter): Declare.
4ac4fd
4ac4fd
2006-02-22  Alexandre Oliva  <aoliva@redhat.com>
4ac4fd
4ac4fd
	* decl2.c (finish_file): Issue warnings for unused parameters
4ac4fd
	of functions not expanded.
4ac4fd
4ac4fd
	* g++.dg/Wunused-parm-1.C: New.
4ac4fd
4ac4fd
--- gcc/cp/decl2.c.orig	2003-08-12 11:12:25.000000000 -0300
4ac4fd
+++ gcc/cp/decl2.c	2006-08-09 16:59:09.000000000 -0300
4ac4fd
@@ -3551,6 +3551,17 @@ finish_file ()
4ac4fd
     } 
4ac4fd
   while (reconsider);
4ac4fd
 
4ac4fd
+  if (warn_unused_parameter)
4ac4fd
+    for (i = 0; i < deferred_fns_used; ++i)
4ac4fd
+      {
4ac4fd
+	tree decl = VARRAY_TREE (deferred_fns, i);
4ac4fd
+
4ac4fd
+	/* Warn about unused parameters in functions we refrained from
4ac4fd
+	   synthesizing.  */
4ac4fd
+	if (!TREE_ASM_WRITTEN (decl))
4ac4fd
+	  do_warn_unused_parameter (decl);
4ac4fd
+      }
4ac4fd
+
4ac4fd
   /* We give C linkage to static constructors and destructors.  */
4ac4fd
   push_lang_context (lang_name_c);
4ac4fd
 
4ac4fd
--- gcc/function.c.orig	2003-10-31 08:42:15.000000000 -0200
4ac4fd
+++ gcc/function.c	2006-08-10 00:28:06.000000000 -0300
4ac4fd
@@ -6808,6 +6808,27 @@ use_return_register ()
4ac4fd
   diddle_return_value (do_use_return_reg, NULL);
4ac4fd
 }
4ac4fd
 
4ac4fd
+/* Warn about unused parms if extra warnings were specified.  */
4ac4fd
+/* Either ``-W -Wunused'' or ``-Wunused-parameter'' enables this
4ac4fd
+   warning.  WARN_UNUSED_PARAMETER is negative when set by
4ac4fd
+   -Wunused.  */
4ac4fd
+void
4ac4fd
+do_warn_unused_parameter (tree fn)
4ac4fd
+{
4ac4fd
+  if (warn_unused_parameter > 0
4ac4fd
+      || (warn_unused_parameter < 0 && extra_warnings))
4ac4fd
+    {
4ac4fd
+      tree decl;
4ac4fd
+
4ac4fd
+      for (decl = DECL_ARGUMENTS (fn);
4ac4fd
+	   decl; decl = TREE_CHAIN (decl))
4ac4fd
+	if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
4ac4fd
+	    && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)
4ac4fd
+	    && ! DECL_IN_SYSTEM_HEADER (decl))
4ac4fd
+	  warning_with_decl (decl, "unused parameter `%s'");
4ac4fd
+    }
4ac4fd
+}
4ac4fd
+
4ac4fd
 /* Generate RTL for the end of the current function.
4ac4fd
    FILENAME and LINE are the current position in the source file.
4ac4fd
 
4ac4fd
@@ -6907,21 +6928,8 @@ expand_function_end (filename, line, end
4ac4fd
 	  }
4ac4fd
     }
4ac4fd
 
4ac4fd
-  /* Warn about unused parms if extra warnings were specified.  */
4ac4fd
-  /* Either ``-W -Wunused'' or ``-Wunused-parameter'' enables this
4ac4fd
-     warning.  WARN_UNUSED_PARAMETER is negative when set by
4ac4fd
-     -Wunused.  */
4ac4fd
-  if (warn_unused_parameter > 0
4ac4fd
-      || (warn_unused_parameter < 0 && extra_warnings))
4ac4fd
-    {
4ac4fd
-      tree decl;
4ac4fd
-
4ac4fd
-      for (decl = DECL_ARGUMENTS (current_function_decl);
4ac4fd
-	   decl; decl = TREE_CHAIN (decl))
4ac4fd
-	if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
4ac4fd
-	    && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
4ac4fd
-	  warning_with_decl (decl, "unused parameter `%s'");
4ac4fd
-    }
4ac4fd
+  if (warn_unused_parameter)
4ac4fd
+    do_warn_unused_parameter (current_function_decl);
4ac4fd
 
4ac4fd
   /* Delete handlers for nonlocal gotos if nothing uses them.  */
4ac4fd
   if (nonlocal_goto_handler_slots != 0
4ac4fd
--- gcc/function.h.orig	2003-06-11 09:56:49.000000000 -0300
4ac4fd
+++ gcc/function.h	2006-08-09 16:59:09.000000000 -0300
4ac4fd
@@ -614,3 +614,5 @@ extern void init_virtual_regs		PARAMS ((
4ac4fd
 
4ac4fd
 /* Called once, at initialization, to initialize function.c.  */
4ac4fd
 extern void init_function_once          PARAMS ((void));
4ac4fd
+
4ac4fd
+extern void do_warn_unused_parameter    PARAMS ((tree));
4ac4fd
--- gcc/testsuite/g++.dg/warn/Wunused-parm-1.C	1970-01-01 00:00:00.000000000 +0000
4ac4fd
+++ gcc/testsuite/g++.dg/warn/Wunused-parm-1.C	2006-08-09 16:59:09.000000000 -0300
4ac4fd
@@ -0,0 +1,27 @@
4ac4fd
+// Test whether we issue warnings for unused parameters, even for
4ac4fd
+// inline functions that are not emitted (without optimization, we
4ac4fd
+// always emit them).
4ac4fd
+// { dg-do compile }
4ac4fd
+// { dg-options "-Wunused-parameter -O" }
4ac4fd
+
4ac4fd
+static inline int foo(int var) { // { dg-warning "unused parameter" }
4ac4fd
+  return 0;
4ac4fd
+}
4ac4fd
+
4ac4fd
+static inline int foo2(int var) { // { dg-warning "unused parameter" }
4ac4fd
+  return 0;
4ac4fd
+}
4ac4fd
+
4ac4fd
+static inline int bar(int var) {
4ac4fd
+  return var;
4ac4fd
+}
4ac4fd
+
4ac4fd
+static inline int bar2(int var) {
4ac4fd
+  return var;
4ac4fd
+}
4ac4fd
+
4ac4fd
+int main() {
4ac4fd
+  foo (1);
4ac4fd
+  bar (2);
4ac4fd
+  return 0;
4ac4fd
+}