Hello world, the attached, rather obvious patch fixed a bogus "unused parameter" warning with procedure dummy arguments and warns about these if they occur.
Regression-tested. OK for trunk? Or rather wait until 4.8? Thomas 2012-02-05 Thomas König <tkoe...@gcc.gnu.org> PR fortran/48847 * trans-decl.c: Warn about unused dummy procedure arguments if -Wunused-dummy-argument is specified. Suppress middle-end warnings about procedure arguments. 2012-02-05 Thomas König <tkoe...@gcc.gnu.org> PR fortran/48847 * gfortran.dg/warn_unused_dummy_argument_3.f90: New test.
Index: trans-decl.c =================================================================== --- trans-decl.c (Revision 183873) +++ trans-decl.c (Arbeitskopie) @@ -4683,6 +4683,22 @@ generate_local_decl (gfc_symbol * sym) && sym->ts.type == BT_CHARACTER && sym->ts.is_c_interop && sym->ns->proc_name != NULL && sym->ns->proc_name->attr.is_bind_c) gfc_conv_scalar_char_value (sym, NULL, NULL); + + /* Unused procedure passed as dummy argument. */ + if (sym->attr.flavor == FL_PROCEDURE) + { + if (!sym->attr.referenced) + { + if (gfc_option.warn_unused_dummy_argument) + gfc_warning ("Unused dummy argument '%s' at %L", sym->name, + &sym->declared_at); + } + + /* Silence bogus "unused parameter" warnings from the + middle end. */ + if (sym->backend_decl != NULL_TREE) + TREE_NO_WARNING(sym->backend_decl) = 1; + } } /* Make sure we convert the types of the derived types from iso_c_binding
! { dg-do compile } ! { dg-options "-Wunused-dummy-argument -Wunused-parameter" } ! PR 48847 - we used to generate a warning for g(), and none for h() program main contains function f(g,h) interface real function g() end function g end interface interface real function h() ! { dg-warning "Unused dummy argument" } end function h end interface real :: f f = g() end function f end program main