This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] PR 52669, warn about unused PRIVATE module variables


Hello world,

here is a rather self-evident patch for PR 52669.

Regression-tested. OK for trunk?

	Thomas


2013-07-12  Thomas Koenig  <tkoenig@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  <tkoenig@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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]