Wunused-parameter warnings are given from cgraph::finalize_function,
which is the middle-end. This is an oddity compared to other -Wunused-* warnings. Moreover, Fortran has its own definition of -Wunused-parameter that conflicts with the middle-end definition. This patch moves the middle-end part of Wunused-parameter to the C/C++ FEs. I'm not sure if other FEs expected this warning to work. If so, they do not seem to test for it. Ada, for example, explicitly disables it. gcc/ChangeLog: 2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66605 * cgraphunit.c (cgraph_node::finalize_function): Do not call do_warn_unused_parameter. * function.c (do_warn_unused_parameter): Move from here. * function.h (do_warn_unused_parameter): Do not declare. gcc/c-family/ChangeLog: 2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66605 * c-common.c (do_warn_unused_parameter): Move here. * c-common.h (do_warn_unused_parameter): Declare. gcc/ada/ChangeLog: 2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66605 * gcc-interface/misc.c (gnat_post_options): No need to disable warn_unused_parameter anymore. gcc/cp/ChangeLog: 2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66605 * decl.c (finish_function): Call do_warn_unused_parameter. gcc/testsuite/ChangeLog: 2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66605 * gfortran.dg/wunused-parameter.f90: New test. gcc/c/ChangeLog: 2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66605 * c-decl.c (finish_function): Call do_warn_unused_parameter. From-SVN: r225135
This commit is contained in:
parent
77f3f9bf9e
commit
da2e71c999
15 changed files with 78 additions and 22 deletions
|
@ -1,3 +1,11 @@
|
|||
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR fortran/66605
|
||||
* cgraphunit.c (cgraph_node::finalize_function): Do not call
|
||||
do_warn_unused_parameter.
|
||||
* function.c (do_warn_unused_parameter): Move from here.
|
||||
* function.h (do_warn_unused_parameter): Do not declare.
|
||||
|
||||
2015-06-29 Matthew Wahab <matthew.wahab@arm.com>
|
||||
|
||||
PR target/65697
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR fortran/66605
|
||||
* gcc-interface/misc.c (gnat_post_options): No need to disable
|
||||
warn_unused_parameter anymore.
|
||||
|
||||
2015-06-26 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu): When
|
||||
|
|
|
@ -262,9 +262,6 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
|
|||
sorry ("-fexcess-precision=standard for Ada");
|
||||
flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
|
||||
|
||||
/* ??? The warning machinery is outsmarted by Ada. */
|
||||
warn_unused_parameter = 0;
|
||||
|
||||
/* No psABI change warnings for Ada. */
|
||||
warn_psabi = 0;
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR fortran/66605
|
||||
* c-common.c (do_warn_unused_parameter): Move here.
|
||||
* c-common.h (do_warn_unused_parameter): Declare.
|
||||
|
||||
2015-06-29 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/66322
|
||||
|
|
|
@ -12103,6 +12103,23 @@ do_warn_double_promotion (tree result_type, tree type1, tree type2,
|
|||
warning_at (loc, OPT_Wdouble_promotion, gmsgid, source_type, result_type);
|
||||
}
|
||||
|
||||
/* Possibly warn about unused parameters. */
|
||||
|
||||
void
|
||||
do_warn_unused_parameter (tree fn)
|
||||
{
|
||||
tree decl;
|
||||
|
||||
for (decl = DECL_ARGUMENTS (fn);
|
||||
decl; decl = DECL_CHAIN (decl))
|
||||
if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
|
||||
&& DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)
|
||||
&& !TREE_NO_WARNING (decl))
|
||||
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_parameter,
|
||||
"unused parameter %qD", decl);
|
||||
}
|
||||
|
||||
|
||||
/* Setup a TYPE_DECL node as a typedef representation.
|
||||
|
||||
X is a TYPE_DECL for a typedef statement. Create a brand new
|
||||
|
|
|
@ -1045,6 +1045,7 @@ extern void warn_for_sign_compare (location_t,
|
|||
tree op0, tree op1,
|
||||
tree result_type,
|
||||
enum tree_code resultcode);
|
||||
extern void do_warn_unused_parameter (tree);
|
||||
extern void do_warn_double_promotion (tree, tree, tree, const char *,
|
||||
location_t);
|
||||
extern void set_underlying_type (tree);
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR fortran/66605
|
||||
* c-decl.c (finish_function): Call do_warn_unused_parameter.
|
||||
|
||||
2015-06-29 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/66322
|
||||
|
|
|
@ -9028,6 +9028,10 @@ finish_function (void)
|
|||
function. */
|
||||
maybe_warn_unused_local_typedefs ();
|
||||
|
||||
/* Possibly warn about unused parameters. */
|
||||
if (warn_unused_parameter)
|
||||
do_warn_unused_parameter (fndecl);
|
||||
|
||||
/* Store the end of the function, so that we get good line number
|
||||
info for the epilogue. */
|
||||
cfun->function_end_locus = input_location;
|
||||
|
|
|
@ -472,10 +472,6 @@ cgraph_node::finalize_function (tree decl, bool no_collect)
|
|||
if (!TREE_ASM_WRITTEN (decl))
|
||||
(*debug_hooks->deferred_inline_function) (decl);
|
||||
|
||||
/* Possibly warn about unused parameters. */
|
||||
if (warn_unused_parameter)
|
||||
do_warn_unused_parameter (decl);
|
||||
|
||||
if (!no_collect)
|
||||
ggc_collect ();
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR fortran/66605
|
||||
* decl.c (finish_function): Call do_warn_unused_parameter.
|
||||
|
||||
2015-06-29 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c/66322
|
||||
|
|
|
@ -14323,6 +14323,12 @@ finish_function (int flags)
|
|||
function. */
|
||||
maybe_warn_unused_local_typedefs ();
|
||||
|
||||
/* Possibly warn about unused parameters. */
|
||||
if (warn_unused_parameter
|
||||
&& !processing_template_decl
|
||||
&& !DECL_CLONED_FUNCTION_P (fndecl))
|
||||
do_warn_unused_parameter (fndecl);
|
||||
|
||||
/* Genericize before inlining. */
|
||||
if (!processing_template_decl)
|
||||
{
|
||||
|
|
|
@ -5210,20 +5210,6 @@ 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 = DECL_CHAIN (decl))
|
||||
if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
|
||||
&& DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)
|
||||
&& !TREE_NO_WARNING (decl))
|
||||
warning (OPT_Wunused_parameter, "unused parameter %q+D", decl);
|
||||
}
|
||||
|
||||
/* Set the location of the insn chain starting at INSN to LOC. */
|
||||
|
||||
static void
|
||||
|
|
|
@ -614,7 +614,6 @@ extern void expand_dummy_function_end (void);
|
|||
extern void thread_prologue_and_epilogue_insns (void);
|
||||
extern void diddle_return_value (void (*)(rtx, void*), void*);
|
||||
extern void clobber_return_register (void);
|
||||
extern void do_warn_unused_parameter (tree);
|
||||
extern void expand_function_end (void);
|
||||
extern rtx get_arg_pointer_save_area (void);
|
||||
extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2015-06-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR fortran/66605
|
||||
* gfortran.dg/wunused-parameter.f90: New test.
|
||||
|
||||
2015-06-29 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* gcc.target/i386/asm-flag-1.c: New.
|
||||
|
|
15
gcc/testsuite/gfortran.dg/wunused-parameter.f90
Normal file
15
gcc/testsuite/gfortran.dg/wunused-parameter.f90
Normal file
|
@ -0,0 +1,15 @@
|
|||
! { dg-do compile }
|
||||
! { dg-options "-Wunused-parameter" }
|
||||
! PR66605
|
||||
MODULE test
|
||||
IMPLICIT NONE
|
||||
INTEGER, PARAMETER :: wp = KIND(1.0D0)
|
||||
CONTAINS
|
||||
SUBROUTINE sub (neq, time, y, dydt)
|
||||
IMPLICIT NONE
|
||||
INTEGER :: neq
|
||||
REAL(WP) :: time, y(neq), dydt(neq)
|
||||
|
||||
dydt(1) = 1.0 / y(1)
|
||||
END SUBROUTINE sub
|
||||
END MODULE
|
Loading…
Add table
Reference in a new issue