https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115653

            Bug ID: 115653
           Summary: USE without ONLY warning when compiling submodules
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gmt3141 at gmail dot com
  Target Milestone: ---

When I compile a submodule with `-Wuse-without-only` option, a false positive
warning about USE without ONLY will be shown:

$ gfortran -Wuse-without-only greeting.f90
greeting.f90:13:19:

   13 | submodule (greet_m) greet_implementation_sm
      |                   1
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! greeting.f90
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

module greet_m

  implicit none

  interface
     module subroutine hello (name)
       character (len=*), intent (in), optional :: name
     end subroutine hello
  end interface

end module greet_m

submodule (greet_m) greet_implementation_sm

contains

  module subroutine hello (name)
    character (len=*), intent (in), optional :: name

    if (present (name)) then
       print '("Hello ", a, "!")', name
    else
       print '("Hello World!")'
    end if
  end subroutine hello

end submodule greet_implementation_sm

program greeting

  use greet_m, only: hello

  implicit none

  call hello
  call hello ('John')

end program greeting

Reply via email to