Hello world, here is a rather self-evident patch for PR 52669.
Regression-tested. OK for trunk? Thomas 2013-07-12 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/52669 * trans-decl.c (gfc_create_module_variable): Optionally warn about private module variable which is not used. 2013-07-12 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/52669 * fortran.dg/module_variable_1.f90: New test.
Index: trans-decl.c =================================================================== --- trans-decl.c (Revision 200743) +++ trans-decl.c (Arbeitskopie) @@ -4212,6 +4212,11 @@ gfc_create_module_variable (gfc_symbol * sym) internal_error ("backend decl for module variable %s already exists", sym->name); + if (warn_unused_variable && !sym->attr.referenced + && sym->attr.access == ACCESS_PRIVATE) + gfc_warning ("Unused PRIVATE module variable '%s' declared at %L", + sym->name, &sym->declared_at); + /* We always want module variables to be created. */ sym->attr.referenced = 1; /* Create the decl. */
! { dg-do compile } ! { dg-options "-Wall" } module foo integer, private :: i ! { dg-warning "Unused PRIVATE" } integer, private :: j = 0 contains subroutine bar j = j + 1 end subroutine bar end module foo