* [Bug fortran/55352] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
@ 2012-11-16 13:43 ` AstroFloyd at gmail dot com
2012-11-16 16:31 ` janus at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: AstroFloyd at gmail dot com @ 2012-11-16 13:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
--- Comment #1 from AstroFloyd <AstroFloyd at gmail dot com> 2012-11-16 13:43:25 UTC ---
Created attachment 28710
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28710
Verbose output from compilation of example source file
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
2012-11-16 13:43 ` [Bug fortran/55352] " AstroFloyd at gmail dot com
@ 2012-11-16 16:31 ` janus at gcc dot gnu.org
2012-11-16 21:43 ` janus at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-16 16:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-11-16
CC| |janus at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #2 from janus at gcc dot gnu.org 2012-11-16 16:31:27 UTC ---
Confirmed.
I guess we should either set attr.referenced in gfc_match_namelist (match.c),
or check for attr.in_namelist in generate_local_decl (trans-decl.c).
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
2012-11-16 13:43 ` [Bug fortran/55352] " AstroFloyd at gmail dot com
2012-11-16 16:31 ` janus at gcc dot gnu.org
@ 2012-11-16 21:43 ` janus at gcc dot gnu.org
2012-11-17 10:55 ` janus at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-16 21:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
--- Comment #3 from janus at gcc dot gnu.org 2012-11-16 21:43:34 UTC ---
(In reply to comment #2)
> I guess we should either set attr.referenced in gfc_match_namelist (match.c),
> or check for attr.in_namelist in generate_local_decl (trans-decl.c).
The latter is what we do for related cases. Proposed patch:
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (revision 193567)
+++ gcc/fortran/trans-decl.c (working copy)
@@ -4589,23 +4589,26 @@ generate_local_decl (gfc_symbol * sym)
}
/* Warn for unused variables, but not if they're inside a common
- block, a namelist, or are use-associated. */
+ block or a namelist. */
else if (warn_unused_variable
- && !(sym->attr.in_common || sym->attr.use_assoc || sym->mark
- || sym->attr.in_namelist))
+ && !(sym->attr.in_common || sym->mark || sym->attr.in_namelist))
{
- gfc_warning ("Unused 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.use_only)
+ {
+ gfc_warning ("Unused module variable '%s' which has been "
+ "explicitly imported at %L", sym->name,
+ &sym->declared_at);
+ if (sym->backend_decl != NULL_TREE)
+ TREE_NO_WARNING(sym->backend_decl) = 1;
+ }
+ else if (!sym->attr.use_assoc)
+ {
+ gfc_warning ("Unused variable '%s' declared at %L",
+ sym->name, &sym->declared_at);
+ if (sym->backend_decl != NULL_TREE)
+ TREE_NO_WARNING(sym->backend_decl) = 1;
+ }
}
- else if (warn_unused_variable && sym->attr.use_only)
- {
- gfc_warning ("Unused module variable '%s' which has been explicitly "
- "imported at %L", sym->name, &sym->declared_at);
- if (sym->backend_decl != NULL_TREE)
- TREE_NO_WARNING(sym->backend_decl) = 1;
- }
/* For variable length CHARACTER parameters, the PARM_DECL already
references the length variable, so force gfc_get_symbol_decl
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
` (2 preceding siblings ...)
2012-11-16 21:43 ` janus at gcc dot gnu.org
@ 2012-11-17 10:55 ` janus at gcc dot gnu.org
2012-11-18 17:53 ` AstroFloyd at gmail dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-17 10:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #4 from janus at gcc dot gnu.org 2012-11-17 10:55:13 UTC ---
(In reply to comment #3)
> Proposed patch:
... regtests cleanly.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
` (3 preceding siblings ...)
2012-11-17 10:55 ` janus at gcc dot gnu.org
@ 2012-11-18 17:53 ` AstroFloyd at gmail dot com
2012-11-18 19:16 ` janus at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: AstroFloyd at gmail dot com @ 2012-11-18 17:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
--- Comment #5 from AstroFloyd <AstroFloyd at gmail dot com> 2012-11-18 17:53:36 UTC ---
Created attachment 28726
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28726
My adaptation of the patch in #3
This solves the problem for me, thank you very much - I'm impressed by your
quick and competent work :-)
Somehow, your patch didn't work in my Gentoo version; I applied your changes
manually and created the attached patch, which can be added to the Gentoo
ebuild for sys-devel/gcc-4.7.2.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
` (4 preceding siblings ...)
2012-11-18 17:53 ` AstroFloyd at gmail dot com
@ 2012-11-18 19:16 ` janus at gcc dot gnu.org
2012-11-19 9:25 ` [Bug fortran/55352] [4.7/4.8 Regression] " janus at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-18 19:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
--- Comment #6 from janus at gcc dot gnu.org 2012-11-18 19:16:27 UTC ---
(In reply to comment #5)
> This solves the problem for me, thank you very much
You're welcome ...
> I'm impressed by your quick and competent work :-)
Thanks! In terms of gfortran bugs, this is certainly one of the easier ones to
fix.
> Somehow, your patch didn't work in my Gentoo version;
My patch was against trunk, so it might not apply cleanly to the 4.7 branch.
The fix will presumably make it into the 4.8 release, but will probably not be
backported to 4.7 (unless you can show that the bug is a regression, i.e. did
not occur in a previous release of gfortran - I haven't checked this).
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] [4.7/4.8 Regression] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
` (5 preceding siblings ...)
2012-11-18 19:16 ` janus at gcc dot gnu.org
@ 2012-11-19 9:25 ` janus at gcc dot gnu.org
2012-11-21 22:20 ` janus at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-19 9:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Erroneous gfortran warning |[4.7/4.8 Regression]
|of unused module variable |Erroneous gfortran warning
|when variable is only used |of unused module variable
|in namelist |when variable is only used
| |in namelist
--- Comment #7 from janus at gcc dot gnu.org 2012-11-19 09:24:53 UTC ---
(In reply to comment #6)
> The fix will presumably make it into the 4.8 release, but will probably not be
> backported to 4.7 (unless you can show that the bug is a regression, i.e. did
> not occur in a previous release of gfortran - I haven't checked this).
Just checked: The bogus warning with -Wall reported here seems to be a 4.7
regression indeed. I verified that it does not occur with 4.3.4, 4.5.3 and
4.6.0.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] [4.7/4.8 Regression] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
` (6 preceding siblings ...)
2012-11-19 9:25 ` [Bug fortran/55352] [4.7/4.8 Regression] " janus at gcc dot gnu.org
@ 2012-11-21 22:20 ` janus at gcc dot gnu.org
2012-11-23 19:05 ` janus at gcc dot gnu.org
2012-11-23 19:10 ` janus at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-21 22:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
--- Comment #8 from janus at gcc dot gnu.org 2012-11-21 22:20:05 UTC ---
Author: janus
Date: Wed Nov 21 22:19:51 2012
New Revision: 193711
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193711
Log:
2012-11-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/55352
* trans-decl.c (generate_local_decl): Don't warn for explicitly imported
but unused module variables which are in a namelist or common block.
2012-11-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/55352
* gfortran.dg/namelist_76.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/namelist_76.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-decl.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] [4.7/4.8 Regression] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
` (7 preceding siblings ...)
2012-11-21 22:20 ` janus at gcc dot gnu.org
@ 2012-11-23 19:05 ` janus at gcc dot gnu.org
2012-11-23 19:10 ` janus at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-23 19:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
--- Comment #9 from janus at gcc dot gnu.org 2012-11-23 19:05:20 UTC ---
Author: janus
Date: Fri Nov 23 19:05:14 2012
New Revision: 193766
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193766
Log:
2012-11-23 Janus Weil <janus@gcc.gnu.org>
PR fortran/55352
* trans-decl.c (generate_local_decl): Don't warn for explicitly imported
but unused module variables which are in a namelist or common block.
2012-11-23 Janus Weil <janus@gcc.gnu.org>
PR fortran/55352
* gfortran.dg/namelist_76.f90: New.
Added:
branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/namelist_76.f90
Modified:
branches/gcc-4_7-branch/gcc/fortran/ChangeLog
branches/gcc-4_7-branch/gcc/fortran/trans-decl.c
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55352] [4.7/4.8 Regression] Erroneous gfortran warning of unused module variable when variable is only used in namelist
2012-11-16 13:42 [Bug fortran/55352] New: Erroneous gfortran warning of unused module variable when variable is only used in namelist AstroFloyd at gmail dot com
` (8 preceding siblings ...)
2012-11-23 19:05 ` janus at gcc dot gnu.org
@ 2012-11-23 19:10 ` janus at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-23 19:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55352
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #10 from janus at gcc dot gnu.org 2012-11-23 19:10:07 UTC ---
The patch in comment 3 has been applied to trunk and the 4.7 branch, which
means the bug will be fixed in the 4.7.3 and 4.8.0 releases. Closing as fixed.
Thanks for the bugreport!
^ permalink raw reply [flat|nested] 11+ messages in thread