tree.h (warn_about_unused_variables): Declare.
authorMark Mitchell <mark@codesourcery.com>
Fri, 17 Sep 1999 22:13:07 +0000 (22:13 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 17 Sep 1999 22:13:07 +0000 (22:13 +0000)
* tree.h (warn_about_unused_variables): Declare.
* stmt.c (warn_about_unused_variables): New function, split out
from ...
(expand_end_bindings): Here.

From-SVN: r29486

gcc/ChangeLog
gcc/stmt.c
gcc/tree.h

index 6b5daedeee0820e9756333a71976f3761fc3a3d4..3a9d61aeefae0c025f1d73cbb9225e1796bbcf9b 100644 (file)
@@ -1,3 +1,10 @@
+Fri Sep 17 15:11:20 1999  Mark Mitchell  <mark@codesourcery.com>
+
+       * tree.h (warn_about_unused_variables): Declare.
+       * stmt.c (warn_about_unused_variables): New function, split out
+       from ...
+       (expand_end_bindings): Here.
+
 Fri Sep 17 15:07:37 1999  Mark Mitchell  <mark@codesourcery.com>
 
        * stmt.c (preserve_subexpressions_p): Don't crash when
index 92465943f8545af8a6856e22fa03c55c49abd258..51110b8a78ddb475ecbf80e53df32f42a7cd3f19 100644 (file)
@@ -3492,6 +3492,25 @@ expand_nl_goto_receivers (thisblock)
   emit_label (afterward);
 }
 
+/* Warn about any unused VARS (which may contain nodes other than
+   VAR_DECLs, but such nodes are ignored).  The nodes are connected
+   via the TREE_CHAIN field.  */
+
+void
+warn_about_unused_variables (vars)
+     tree vars;
+{
+  tree decl;
+
+  if (warn_unused)
+    for (decl = vars; decl; decl = TREE_CHAIN (decl))
+      if (TREE_CODE (decl) == VAR_DECL 
+         && ! TREE_USED (decl)
+         && ! DECL_IN_SYSTEM_HEADER (decl)
+         && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) 
+       warning_with_decl (decl, "unused variable `%s'");
+}
+
 /* Generate RTL code to terminate a binding contour.
 
    VARS is the chain of VAR_DECL nodes for the variables bound in this
@@ -3532,13 +3551,9 @@ expand_end_bindings (vars, mark_ends, dont_jump_in)
      
   thisblock = block_stack;
 
-  if (warn_unused)
-    for (decl = vars; decl; decl = TREE_CHAIN (decl))
-      if (TREE_CODE (decl) == VAR_DECL 
-         && ! TREE_USED (decl)
-         && ! DECL_IN_SYSTEM_HEADER (decl)
-         && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) 
-       warning_with_decl (decl, "unused variable `%s'");
+  /* If any of the variables in this scope were not used, warn the
+     user.  */
+  warn_about_unused_variables (vars);
 
   if (thisblock->exit_label)
     {
index 669e9efbc4b70a1cb2b97a1641b3c844a91bb766..e479f99a1bbebdb3d1cbbe76c0aa86d6fcbb22a5 100644 (file)
@@ -2054,6 +2054,7 @@ extern void expand_return                 PROTO((tree));
 extern int optimize_tail_recursion             PROTO((tree, struct rtx_def *));
 extern void expand_start_bindings              PROTO((int));
 extern void expand_end_bindings                        PROTO((tree, int, int));
+extern void warn_about_unused_variables         PROTO((tree));
 extern void start_cleanup_deferral             PROTO((void));
 extern void end_cleanup_deferral               PROTO((void));
 extern void mark_block_as_eh_region            PROTO((void));