diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-09-17 22:13:07 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-09-17 22:13:07 +0000 |
commit | ba7166773bd7a4d1e0da5bad0a61c20fac3bef78 (patch) | |
tree | eb5f3deca9fe795ca483b7f9c976536796c57c50 /gcc/stmt.c | |
parent | 086925d8cc71897027ae9407fcfd0def1d767b1e (diff) | |
download | gcc-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/stmt.c')
-rw-r--r-- | gcc/stmt.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -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) { |