[F08] Bug 79447 - gfortran rejects valid & accepts invalid internal subprogram in a submodule

Damian Rouson damian@sourceryinstitute.org
Thu Feb 9 21:00:00 GMT 2017


A recent build of gfortran 7 doesn’t allow an internal subprogram to be contained inside a module subprogram when the subprogram is in a submodule and is implemented with the “module procedure” keywords instead of “module subroutine”.  See below.  gfortran 6.3.0 exhibits the same behavior.  It would be great if any fix can also be back-ported to the 6 branch.  This has been submitted as the above-referenced bug report.

ifort 17 compiles the code below without error.  

Damian


$ cat procedure-contains.f90 
module foo_interface
  implicit none
  interface
    module subroutine foo()
    end subroutine
  end interface
end module foo_interface

submodule(foo_interface) foo_implementation
contains
    module procedure foo
    contains
      module subroutine bar()
      end subroutine
    end procedure
   !end subroutine ! gfortran accepts this invalid workaround
end submodule 

$ gfortran procedure-contains.f90 
procedure-contains.f90:15:7:

     end procedure
       1
Error: Expecting END SUBROUTINE statement at (1)
procedure-contains.f90:17:3:

 end submodule
   1
Error: Expecting END SUBROUTINE statement at (1)
f951: Error: Unexpected end of file in 'procedure-contains.f90'

$ gfortran --version
GNU Fortran (MacPorts gcc7 7-20170108_0) 7.0.0 20170108 (experimental)



More information about the Fortran mailing list