aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-09-17 22:13:07 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-09-17 22:13:07 +0000
commitba7166773bd7a4d1e0da5bad0a61c20fac3bef78 (patch)
treeeb5f3deca9fe795ca483b7f9c976536796c57c50 /gcc
parent086925d8cc71897027ae9407fcfd0def1d767b1e (diff)
downloadgcc-ba7166773bd7a4d1e0da5bad0a61c20fac3bef78.zip
gcc-ba7166773bd7a4d1e0da5bad0a61c20fac3bef78.tar.gz
gcc-ba7166773bd7a4d1e0da5bad0a61c20fac3bef78.tar.bz2
tree.h (warn_about_unused_variables): Declare.
* 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/stmt.c29
-rw-r--r--gcc/tree.h1
3 files changed, 30 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6b5daed..3a9d61a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 9246594..51110b8 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -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)
{
diff --git a/gcc/tree.h b/gcc/tree.h
index 669e9ef..e479f99 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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));