mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 15:36:49 +00:00

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
55 lines
937 B
Fortran
55 lines
937 B
Fortran
! RUN: %python %S/test_modfile.py %s %flang_fc1
|
|
! Ensure that m2.mod explicitly USEs a generic interface from m1
|
|
! so it can utilize its shadowed derived type.
|
|
module m1
|
|
implicit none
|
|
type :: xyz
|
|
integer :: n
|
|
end type
|
|
interface xyz
|
|
module procedure xzy
|
|
end interface
|
|
contains
|
|
function xzy(j) result(res)
|
|
integer, intent(in) :: j
|
|
type(xyz) :: res
|
|
res%n = j
|
|
end function
|
|
end module
|
|
|
|
!Expect: m1.mod
|
|
!module m1
|
|
!type::xyz
|
|
!integer(4)::n
|
|
!end type
|
|
!interface xyz
|
|
!procedure::xzy
|
|
!end interface
|
|
!contains
|
|
!function xzy(j) result(res)
|
|
!integer(4),intent(in)::j
|
|
!type(xyz)::res
|
|
!end
|
|
!end
|
|
|
|
module m2
|
|
implicit none
|
|
contains
|
|
function foo(j) result(res)
|
|
use :: m1, only: xyz
|
|
integer, intent(in) :: j
|
|
type(xyz) :: res
|
|
res = xyz(j)
|
|
end function
|
|
end module
|
|
|
|
!Expect: m2.mod
|
|
!module m2
|
|
!contains
|
|
!function foo(j) result(res)
|
|
!use m1,only:xyz
|
|
!integer(4),intent(in)::j
|
|
!type(xyz)::res
|
|
!end
|
|
!end
|