Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

false positive for /warn:unused if use module, only : variable in an interface definition

$
0
0

 

Hi all,

I use ifort 15.0.0.108 and observed the following issue:

If I use the

use module, only : var_a
instead of
use module
in an interface I get IMHO a false positive warning of unused variables. This can be seen best in the following example compiled with ‘/warn:unuse’:

warning_unused.f90:

program warning_unused
    use mod_bar
    implicit none
    ! Interfaces
    interface
      subroutine foo(text)
        !use mod_bar                     ! as expected no waring
        use mod_bar, only : var_a, var_b ! warning_unused.f90(22): remark #7712: This variable has not been used.   [VAR_A] [VAR_B]
        implicit none
        character(len=*) :: text
      end subroutine foo
    end interface
 
    ! Variables
    character(len=20) :: text
 
    ! Body of warning_unused
    text = 'Hello World'
    call foo(trim(text))
end program warning_unused
 
mod_bar.f90:
module mod_bar
  integer :: var_a, var_b
end module mod_bar
 
foo.f90:
subroutine foo(text)
  use mod_bar, only : var_a, var_b
  implicit none
  character(len=*) :: text
  write(*,'(a)') text
  var_a = 10
  var_b = 20
end subroutine foo

If I leave out the only statement I get no warning, as I expected. But with ‘only : var_a, var_b’ I get:

\warning_unused.f90(22): remark #7712: This variable has not been used.   [VAR_A]

\warning_unused.f90(22): remark #7712: This variable has not been used.   [VAR_B]

 

This is not what I  like to have. Because now I have to look twice on the warning and have to check, whether it is in an interface…

Have I done something wrong?

Best regards, Johannes


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>