Files
clang-p2996/flang/test/Semantics/modfile38.f90
Peter Klausler a3e9d3c2c7 [flang] Allow reference to earlier generic in later interface
Name resolutions defers all resolution and checking of specific procedures
in non-type-bound generic interfaces to the end of the specification part.
This prevents expression analysis of references to generic functions in
specification expressions in interfaces from resolving.

Example (now a new test case in modfile07.f90):
```
  module m12
    interface generic
      module procedure specific
    end interface
    interface
      module subroutine s(a1,a2)
        character(*) a1
        character(generic(a1)) a2   ! <--
      end
    end interface
   contains
    pure integer function specific(x)
      character(*), intent(in) :: x
      specific = len(x)
    end
  end
```

The solution is to partially resolve specific procedures as they are
defined for each generic, when they can be resolved, with the final
pass at the end of the specification part to finish up any forward
references and emit the necessary error messages.

Making this fix caused some issues in module file output, which have
all been resolved by making this simplifying change: generics are
now all emitted to module file specification parts as their own
group of declarations at the end of the specification part,
followed only by namelists and COMMON blocks.

Differential Revision: https://reviews.llvm.org/D157346
2023-08-08 12:19:53 -07:00

36 lines
554 B
Fortran

! RUN: %python %S/test_modfile.py %s %flang_fc1
! Ensure that an interface with the same name as a derived type
! does not cause that shadowed name to be emitted later than its
! uses in the module file.
module m
type :: t
end type
type :: t2
type(t) :: c
end type
interface t
module procedure f
end interface
contains
type(t) function f
end function
end module
!Expect: m.mod
!module m
!type::t
!end type
!type::t2
!type(t)::c
!end type
!interface t
!procedure::f
!end interface
!contains
!function f()
!type(t)::f
!end
!end