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

            Bug ID: 125527
           Summary: Submodule cannot access internal subprograms of
                    ancestor module via host association
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jvdelisle at gcc dot gnu.org
  Target Milestone: ---

A submodule incorrectly rejects references to internal subprograms of its
ancestor module that should be
  visible via host association.  Fortran 2018 ยง14.6.1.3 requires submodules to
host-associate the specification
  part and module subprogram part of their ancestor module.  Intel Fortran and
NAG Fortran accept this usage.

  The error message is:

  error: 'double_it' has no IMPLICIT type

  Reproducer (mod.f90):

  module m
    implicit none
    private
    public :: test

    interface
      module subroutine test()
      end subroutine
    end interface

  contains
    pure function double_it(x) result(y)
      double precision, intent(in) :: x
      double precision :: y
      y = 2.0d0 * x
    end function

  end module m

  Reproducer (sub.f90):

  submodule(m) s
    implicit none
  contains
    module subroutine test()
      if (abs(double_it(3.0d0) - 6.0d0) > 1d-10) stop 1
    end subroutine
  end submodule s

  program p
    use m
    implicit none
    call test()
  end program p

$ gfortran mod.f90 sub.f90

gfortran rejects double_it in the submodule body with "has no IMPLICIT type". 
The program should compile and run cleanly.

Reply via email to