diff options
author | Jan Hubicka <jh@suse.cz> | 2004-04-28 22:40:55 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2004-04-28 20:40:55 +0000 |
commit | 902edd367b9d585a610eabdad8110a188effd707 (patch) | |
tree | d5b0b3986f7580e9e8e84df766ad4bfe9caaa82e /gcc/function.c | |
parent | a89f5df3d9325c1d5d9ed7f92abd6c61f9df8631 (diff) | |
download | gcc-902edd367b9d585a610eabdad8110a188effd707.tar.gz |
re PR c/15004 ([unit-at-a-time] no warning for unused paramater in static function)
* gcc.dg/unused-6.c: New test.
PR c/15004
* function.c (do_warn_unused_parameter): Break out form ...
(expand_function_end): ... here; warn only when not using cgraphunit.
* function.h (do_warn_unused_parameter): Declare.
* cgraphunit.c: Include function.h.
(cgraph_finalize_function): Do unused parameter warning.
* Makefile.in (cgraphunit.o): Depend on function.h
From-SVN: r81260
Diffstat (limited to 'gcc/function.c')
-rw-r--r-- | gcc/function.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/gcc/function.c b/gcc/function.c index 69f9b8f568b..b1f888f141f 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -6919,6 +6919,19 @@ use_return_register (void) diddle_return_value (do_use_return_reg, NULL); } +/* Possibly warn about unused parameters. */ +void +do_warn_unused_parameter (tree fn) +{ + tree decl; + + for (decl = DECL_ARGUMENTS (fn); + decl; decl = TREE_CHAIN (decl)) + if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL + && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)) + warning ("%Junused parameter '%D'", decl, decl); +} + static GTY(()) rtx initial_trampoline; /* Generate RTL for the end of the current function. */ @@ -7007,17 +7020,12 @@ expand_function_end (void) } } - /* Possibly warn about unused parameters. */ - if (warn_unused_parameter) - { - tree decl; - - for (decl = DECL_ARGUMENTS (current_function_decl); - decl; decl = TREE_CHAIN (decl)) - if (! TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL - && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) - warning ("%Junused parameter '%D'", decl, decl); - } + /* Possibly warn about unused parameters. + When frontend does unit-at-a-time, the warning is already + issued at finalization time. */ + if (warn_unused_parameter + && !lang_hooks.callgraph.expand_function) + do_warn_unused_parameter (current_function_decl); /* Delete handlers for nonlocal gotos if nothing uses them. */ if (nonlocal_goto_handler_slots != 0 |