https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93309
            Bug ID: 93309
           Summary: Wrong error about duplicate implicit none
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ripero84 at gmail dot com
  Target Milestone: ---

gfortran thinks the following module code is wrong:


$ cat ine.f90 
module m
  implicit none(external)
contains
  subroutine s
    implicit none(external)
  end subroutine
end module
$ gfortran-9 -std=f2018 ine.f90 -c -o ine.o
ine.f90:5:17:

    5 |     implicit none(external)
      |                 1
Error: Duplicate IMPLICIT NONE statement at (1)


As far as I can see, this is valid Fortran 2018: when the standard says

"C891 [...] No more than one IMPLICIT NONE statement shall appear in a scoping
unit."

one has to bear in mind that a module and a contained subprogram are two
different scoping units.  And while

"C895 If IMPLICIT NONE with an implicit-none-spec of EXTERNAL appears within a
scoping unit, the name of an external or dummy procedure in that scoping unit
or in a contained subprogram or BLOCK construct shall have [...]"

means that the effects of a module-level IMPLICIT NONE(EXTERNAL) also extend to
the subprograms the module contains, it does not forbid repeating an IMPLICIT
NONE(EXTERNAL) statement in them.

If there is another reason why this is forbidden I would like to know.

Reply via email to