This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for Warning About Unused Parameters
- To: egcs-patches at cygnus dot com
- Subject: Patch for Warning About Unused Parameters
- From: Dave Brolley <brolley at cygnus dot com>
- Date: Wed, 20 Jan 1999 18:24:33 -0500
- Organization: Cygnus Solutions Canada Ltd
Hi,
Attached is a patch which corrects a problem where warning are not
generated for some unused function parameters. Compiling the attached
test case with -W -Wall -O results in no warnings for arg3 and arg5.
Dave
13529.c
Index: function.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/function.c,v
retrieving revision 1.65
diff -c -p -c -p -r1.65 function.c
*** function.c 1999/01/19 10:31:52 1.65
--- function.c 1999/01/20 23:01:08
*************** assign_parms (fndecl, second_time)
*** 4378,4383 ****
--- 4378,4384 ----
if (nominal_mode != passed_mode
|| promoted_nominal_mode != promoted_mode)
{
+ int save_tree_used;
/* ENTRY_PARM has been converted to PROMOTED_MODE, its
mode, by the caller. We now have to convert it to
NOMINAL_MODE, if different. However, PARMREG may be in
*************** assign_parms (fndecl, second_time)
*** 4404,4411 ****
--- 4405,4415 ----
push_to_sequence (conversion_insns);
tempreg = convert_to_mode (nominal_mode, tempreg, unsignedp);
+ /* TREE_USED gets set erroneously during expand_assignment. */
+ save_tree_used = TREE_USED (parm);
expand_assignment (parm,
make_tree (nominal_type, tempreg), 0, 0);
+ TREE_USED (parm) = save_tree_used;
conversion_insns = get_insns ();
did_conversion = 1;
end_sequence ();