public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/54224] Warn for unused (private) module variables and internal procedures
Date: Sat, 20 Oct 2012 21:18:00 -0000	[thread overview]
Message-ID: <bug-54224-4-62w0c0cuHQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-54224-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54224

--- Comment #15 from janus at gcc dot gnu.org 2012-10-20 21:17:54 UTC ---
(In reply to comment #14)
> (In reply to comment #12)
> >  * unused-warnings for module variables

Here is a draft patch which fixes the test case in comment 14:

Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c    (revision 192619)
+++ gcc/fortran/trans-decl.c    (working copy)
@@ -3999,6 +4001,20 @@ static void
       && sym->ts.type == BT_DERIVED)
     sym->backend_decl = gfc_typenode_for_spec (&(sym->ts));

+  /* Warn for unused private module variables.  */
+  if (warn_unused_variable && !sym->attr.referenced
+      && (sym->attr.access == ACCESS_PRIVATE
+      || (sym->attr.access == ACCESS_UNKNOWN
+          && sym->ns->default_access == ACCESS_PRIVATE))
+      && !(sym->attr.in_common || sym->attr.use_assoc || sym->mark
+       || sym->attr.in_namelist || sym->attr.flavor == FL_MODULE))
+    {
+      gfc_warning ("Unused private module variable '%s' declared at %L",
+           sym->name, &sym->declared_at);
+      if (sym->backend_decl != NULL_TREE)
+    TREE_NO_WARNING(sym->backend_decl) = 1;
+    }
+
   if (sym->attr.flavor == FL_DERIVED
       && sym->backend_decl
       && TREE_CODE (sym->backend_decl) == RECORD_TYPE)


as well as this extended version (and regtests cleanly):


module m
 integer :: j
 integer, private :: k   ! { dg-error "Unused private module variable" }
end module

module m2
  private
  real :: r              ! { dg-error "Unused private module variable" }
  real, public :: p
end module


  parent reply	other threads:[~2012-10-20 21:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 15:44 [Bug middle-end/54224] New: [4.8 Regression] Bogus -Wunused-function warning with static function burnus at gcc dot gnu.org
2012-08-11  9:03 ` [Bug middle-end/54224] " burnus at gcc dot gnu.org
2012-08-15 12:39 ` burnus at gcc dot gnu.org
2012-08-15 13:04 ` burnus at gcc dot gnu.org
2012-08-15 18:30 ` [Bug middle-end/54224] [4.8 Regression] " janus at gcc dot gnu.org
2012-08-16  9:57 ` burnus at gcc dot gnu.org
2012-08-16 11:07 ` rguenth at gcc dot gnu.org
2012-08-21  8:49 ` burnus at gcc dot gnu.org
2012-09-15 17:42 ` [Bug fortran/54224] " janus at gcc dot gnu.org
2012-09-15 17:48 ` burnus at gcc dot gnu.org
2012-09-15 18:26 ` janus at gcc dot gnu.org
2012-09-19 14:25 ` rguenth at gcc dot gnu.org
2012-10-19 17:15 ` janus at gcc dot gnu.org
2012-10-19 17:23 ` janus at gcc dot gnu.org
2012-10-19 17:49 ` janus at gcc dot gnu.org
2012-10-19 17:54 ` [Bug fortran/54224] Warn for unused (private) module variables and internal procedures janus at gcc dot gnu.org
2012-10-20 21:18 ` janus at gcc dot gnu.org [this message]
2013-03-22 14:45 ` jakub at gcc dot gnu.org
2013-05-31 10:59 ` jakub at gcc dot gnu.org
2013-08-19 21:18 ` janus at gcc dot gnu.org
2013-08-19 21:22 ` [Bug fortran/54224] Warn for unused " janus at gcc dot gnu.org
2013-10-16  9:51 ` jakub at gcc dot gnu.org
2015-06-22 14:26 ` rguenth at gcc dot gnu.org
2015-09-13 13:45 ` dominiq at lps dot ens.fr
2015-09-13 15:04 ` manu at gcc dot gnu.org
2015-09-13 15:24 ` dominiq at lps dot ens.fr
2015-09-13 15:52 ` manu at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-54224-4-62w0c0cuHQ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).