public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables.
@ 2011-07-09 22:25 stephan.kramer at imperial dot ac.uk
2011-08-12 19:39 ` [Bug fortran/49693] " longb at cray dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: stephan.kramer at imperial dot ac.uk @ 2011-07-09 22:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
Summary: Spurious "unused-variable" warnings for COMMON block
module variables.
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: stephan.kramer@imperial.ac.uk
As of gfortran 4.6, module variables that are also part of a common block cause
spurious "unused variable" warnings. The following example
module foo
implicit none
integer:: a, b
common a
end module foo
produces:
$ gfortran -c -Wall test.f90
test.f90:3:0: warning: ‘a’ defined but not used [-Wunused-variable]
Although common variables are deprecated they're still commonly used in
libraries such as mpi and petsc to define some global paramaters. I therefore
get quite a few warning messages in every module that uses these (and also
everywhere module that subsequently uses such modules). Example here with
openmpi:
$ cat test.f90
module foo
use mpi
use petsc
end module
$ mpif90 -I/usr/lib/petscdir/3.1/linux-gnu-c-opt/include/ -Wall -c test.f90
test.f90:2:0: warning: ‘mpi_argv_null’ defined but not used
test.f90:2:0: warning: ‘mpi_in_place’ defined but not used
test.f90:2:0: warning: ‘mpi_status_ignore’ defined but not used
test.f90:2:0: warning: ‘mpi_statuses_ignore’ defined but not used
test.f90:3:0: warning: ‘petsc_comm_self’ defined but not used
test.f90:3:0: warning: ‘petsc_null_integer’ defined but not used
test.f90:3:0: warning: ‘petsc_null’ defined but not used
test.f90:3:0: warning: ‘petsc_null_scalar’ defined but not used
test.f90:3:0: warning: ‘petsc_null_double’ defined but not used
test.f90:3:0: warning: ‘petsc_null_real’ defined but not used
test.f90:3:0: warning: ‘petsc_null_truth’ defined but not used
test.f90:2:0: warning: ‘mpi_argvs_null’ defined but not used
test.f90:3:0: warning: ‘petsc_null_object’ defined but not used
test.f90:3:0: warning: ‘petsc_comm_world’ defined but not used
test.f90:2:0: warning: ‘mpi_argv_null’ defined but not used
test.f90:2:0: warning: ‘mpi_argvs_null’ defined but not used
test.f90:2:0: warning: ‘mpi_bottom’ defined but not used
test.f90:2:0: warning: ‘mpi_errcodes_ignore’ defined but not used
test.f90:2:0: warning: ‘mpi_in_place’ defined but not used
test.f90:2:0: warning: ‘mpi_status_ignore’ defined but not used
test.f90:2:0: warning: ‘mpi_statuses_ignore’ defined but not used
test.f90:3:0: warning: ‘petsc_null_character’ defined but not used
test.f90:2:0: warning: ‘mpi_bottom’ defined but not used
test.f90:2:0: warning: ‘mpi_errcodes_ignore’ defined but not used
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/49693] Spurious "unused-variable" warnings for COMMON block module variables.
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
@ 2011-08-12 19:39 ` longb at cray dot com
2011-12-30 0:26 ` harald at klimachs dot de
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: longb at cray dot com @ 2011-08-12 19:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
Bill Long <longb at cray dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |longb at cray dot com
--- Comment #1 from Bill Long <longb at cray dot com> 2011-08-12 19:22:50 UTC ---
Had a user support with similar issues when using the MPI module. Test case:
module dmi_mpi_global
use mpi
implicit none
private
logical, save, public :: debug_print
integer(4), save, public :: iu06
integer(4), save, public :: mpi_io_rank = 0
character(LEN=256), save, public :: mpi_decomp_file = 'mpi_decompo.txt'
public :: dmpi_close
contains
subroutine dmpi_close ( flag )
implicit none
logical, intent(in) :: flag
integer(4) :: ierr
if (flag) then
write(*,'(a19)') 'Time to die for MPI'
else
write(iu06,'(a19)') 'Time to die for MPI'
endif
if (.not.flag) close (iu06)
call mpi_finalize(ierr)
end subroutine dmpi_close
end module dmi_mpi_global
> ftn -c -Wall test.f90
test.f90:2:0: warning: 'mpi_bottom' defined but not used [-Wunused-variable]
test.f90:2:0: warning: 'mpi_in_place' defined but not used [-Wunused-variable]
test.f90:2:0: warning: 'mpi_status_ignore' defined but not used
[-Wunused-variable]
test.f90:2:0: warning: 'mpi_statuses_ignore' defined but not used
[-Wunused-variable]
test.f90:2:0: warning: 'mpi_errcodes_ignore' defined but not used
[-Wunused-variable]
test.f90:2:0: warning: 'mpi_unweighted' defined but not used
[-Wunused-variable]
test.f90:2:0: warning: 'mpi_argvs_null' defined but not used
[-Wunused-variable]
test.f90:2:0: warning: 'mpi_argv_null' defined but not used [-Wunused-variable]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/49693] Spurious "unused-variable" warnings for COMMON block module variables.
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
2011-08-12 19:39 ` [Bug fortran/49693] " longb at cray dot com
@ 2011-12-30 0:26 ` harald at klimachs dot de
2012-01-01 16:37 ` tkoenig at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: harald at klimachs dot de @ 2011-12-30 0:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
Harald Klimach <harald at klimachs dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at klimachs dot de
--- Comment #2 from Harald Klimach <harald at klimachs dot de> 2011-12-30 00:12:07 UTC ---
Just also want to confirm this, I get the same messages with the mpi module of
openmpi. And I wanted to add, that these messages even persist, if I use an
only clause in the use mpi statement.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/49693] Spurious "unused-variable" warnings for COMMON block module variables.
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
2011-08-12 19:39 ` [Bug fortran/49693] " longb at cray dot com
2011-12-30 0:26 ` harald at klimachs dot de
@ 2012-01-01 16:37 ` tkoenig at gcc dot gnu.org
2012-01-03 12:36 ` tkoenig at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-01-01 16:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tkoenig at gcc dot gnu.org
--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-01-01 16:37:27 UTC ---
Testing this patch:
Index: toplev.c
===================================================================
--- toplev.c (Revision 182754)
+++ toplev.c (Arbeitskopie)
@@ -501,6 +501,9 @@
to handle multiple external decls in different scopes. */
&& ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
&& ! DECL_EXTERNAL (decl)
+ /* Don't warn about variables in Fortran common blocks because
+ they may be used elsewhere. */
+ && ! DECL_COMMON(decl)
&& ! TREE_PUBLIC (decl)
/* A volatile variable might be used in some non-obvious way. */
&& ! TREE_THIS_VOLATILE (decl)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/49693] Spurious "unused-variable" warnings for COMMON block module variables.
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
` (2 preceding siblings ...)
2012-01-01 16:37 ` tkoenig at gcc dot gnu.org
@ 2012-01-03 12:36 ` tkoenig at gcc dot gnu.org
2012-01-04 11:52 ` tkoenig at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-01-03 12:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-01-03 12:36:28 UTC ---
(In reply to comment #3)
> Testing this patch:
which doesn't work.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/49693] Spurious "unused-variable" warnings for COMMON block module variables.
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
` (3 preceding siblings ...)
2012-01-03 12:36 ` tkoenig at gcc dot gnu.org
@ 2012-01-04 11:52 ` tkoenig at gcc dot gnu.org
2012-01-04 11:56 ` tkoenig at gcc dot gnu.org
2012-01-04 18:41 ` harald at klimachs dot de
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-01-04 11:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-01-04 11:51:40 UTC ---
Author: tkoenig
Date: Wed Jan 4 11:51:37 2012
New Revision: 182869
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182869
Log:
2012-01-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49693
* trans-common.c (create_common): Update copyright years. Mark
variables as used to avoid warnings about unused variables in
common blocks.
2012-01-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49693
* gfortran.dg/common_17.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/common_17.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-common.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/49693] Spurious "unused-variable" warnings for COMMON block module variables.
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
` (4 preceding siblings ...)
2012-01-04 11:52 ` tkoenig at gcc dot gnu.org
@ 2012-01-04 11:56 ` tkoenig at gcc dot gnu.org
2012-01-04 18:41 ` harald at klimachs dot de
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-01-04 11:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-01-04 11:55:15 UTC ---
Fixed on trunk, closing.
If somebody really, really wants a backport to 4.6, please speak up.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/49693] Spurious "unused-variable" warnings for COMMON block module variables.
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
` (5 preceding siblings ...)
2012-01-04 11:56 ` tkoenig at gcc dot gnu.org
@ 2012-01-04 18:41 ` harald at klimachs dot de
6 siblings, 0 replies; 8+ messages in thread
From: harald at klimachs dot de @ 2012-01-04 18:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49693
--- Comment #7 from Harald Klimach <harald at klimachs dot de> 2012-01-04 18:41:08 UTC ---
Thanks a lot!
Just ran the gcc trunk over my code, and the annoying warnings are gone.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-01-04 18:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-09 22:25 [Bug fortran/49693] New: Spurious "unused-variable" warnings for COMMON block module variables stephan.kramer at imperial dot ac.uk
2011-08-12 19:39 ` [Bug fortran/49693] " longb at cray dot com
2011-12-30 0:26 ` harald at klimachs dot de
2012-01-01 16:37 ` tkoenig at gcc dot gnu.org
2012-01-03 12:36 ` tkoenig at gcc dot gnu.org
2012-01-04 11:52 ` tkoenig at gcc dot gnu.org
2012-01-04 11:56 ` tkoenig at gcc dot gnu.org
2012-01-04 18:41 ` harald at klimachs dot de
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).