===================================================================
@@ -12045,10 +12045,27 @@ do_warn_double_promotion (tree result_ty
else
return;
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
..._TYPE node (which will be just a variant of the existing
..._TYPE node with identical properties) and then install X
===================================================================
@@ -1041,10 +1041,11 @@ extern void warn_for_div_by_zero (locati
extern void warn_for_sign_compare (location_t,
tree orig_op0, tree orig_op1,
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);
extern void record_types_used_by_current_var_decl (tree);
extern void record_locally_defined_typedef (tree);
===================================================================
@@ -9026,10 +9026,14 @@ finish_function (void)
/* Complain about locally defined typedefs that are not used in this
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;
/* Finalize the ELF visibility for the function. */
===================================================================
@@ -470,14 +470,10 @@ cgraph_node::finalize_function (tree dec
/* If we've not yet emitted decl, tell the debug info about it. */
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 ();
if (symtab->state == CONSTRUCTION
&& (node->needed_p () || node->referred_to_p ()))
===================================================================
@@ -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
===================================================================
@@ -14313,10 +14313,16 @@ finish_function (int flags)
/* Complain about locally defined typedefs that are not used in this
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)
{
struct language_function *f = DECL_SAVED_FUNCTION_DATA (fndecl);
invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
===================================================================
@@ -259,13 +259,10 @@ gnat_post_options (const char **pfilenam
if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
&& TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
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;
/* No caret by default for Ada. */
if (!global_options_set.x_flag_diagnostics_show_caret)
===================================================================
@@ -5208,24 +5208,10 @@ static void
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
set_insn_locations (rtx_insn *insn, int loc)
{
===================================================================
@@ -612,11 +612,10 @@ extern void expand_function_start (tree)
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);
extern int prologue_epilogue_contains (const_rtx);
extern void emit_return_into_block (bool simple_p, basic_block bb);