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

            Bug ID: 58177
           Summary: Incorrect warning message about unused PRIVATE module
                    variable
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abensonca at gmail dot com

With gfortran 4.9.0 (r201758) the following incorrectly reports than the
variable "m" in module "b" is unused:

module a
  logical :: m
end module a
module b
  logical, private :: m
contains
  subroutine bb()
    use a
    m=.true.
  end subroutine bb
end module b

$ gfortran -v                                                                   
Using built-in specs.                                                           
COLLECT_GCC=gfortran                                                            
COLLECT_LTO_WRAPPER=/home/abenson/Galacticus/Tools/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
 
Target: x86_64-unknown-linux-gnu                                                
Configured with: ../gcc-trunk/configure --prefix=/home/abenson/Galacticus/Tools
--enable-languages=c,c++,fortran --disable-multilib
--with-gmp=/home/abenson/Galacticus/Tools                                       
Thread model: posix                                                             
gcc version 4.9.0 20130815 (experimental) (GCC)                                 
$ gfortran -c bug.F90 -o bug.o -Wall
bug.F90:5.23:                                                                   

  logical, private :: m                                                         
                       1
Warning: Unused PRIVATE module variable 'm' declared at (1)

The variable "m" in module "b" is used. The problem seems to be related to the
presence of a PUBLIC variable with the same name in another USEd module.
Changing the name of the variable in the USEd module makes the warning go away.
Renaming the imported variable with:

    use a, only : mm => m

results in a correct warning:

Warning: Unused module variable 'm' which has been explicitly imported at (1)

and causes the "Unused PRIVATE" warning to go away.

Reply via email to