Blame SOURCES/gcc32-rh181894.patch

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