Hello! A file that used to be able to compile with nvfortran < 25.9 is failing now with 25.9 with the error code: NVFORTRAN-S-1257-Interface test_interface must be declared. (mre.f90)
Attached is an MRE with the fix I had to do. Essentially, the compiler seems to not be looking further down and needs specific import xyz to work. I don’t know if this is a compiler bug or a really strict enforcing of the standard :)
module td_mre
implicit none
private
public :: run_testsuite, new_unittest, unittest_type
public :: test_interface, collect_interface
! A simple error type in host scope
type :: error_type
integer :: stat = 0
character(len=:), allocatable :: message
end type error_type
! Abstract interface for tests; uses error_type from host via import
abstract interface
subroutine test_interface(error)
import
type(error_type), allocatable, intent(out) :: error
end subroutine test_interface
end interface
public :: test_interface
! Type that stores a procedure pointer with that interface
type :: unittest_type
character(len=:), allocatable :: name
procedure(test_interface), pointer, nopass :: test => null()
end type unittest_type
public :: unittest_type
! Abstract interface that imports only unittest_type
! (missing: test_interface) <-- this triggers S-1257 indirectly
abstract interface
subroutine collect_interface(testsuite)
import :: unittest_type
!works:
!import :: unittest_type, test_interface
type(unittest_type), allocatable, intent(out) :: testsuite(:)
end subroutine collect_interface
end interface
public :: collect_interface
contains
recursive subroutine run_testsuite(collect, unit, stat)
procedure(collect_interface) :: collect ! <-- NVFORTRAN-S-1257 here
integer, intent(in) :: unit
integer, intent(out) :: stat
type(unittest_type), allocatable :: tests(:)
stat = 0
call collect(tests)
end subroutine run_testsuite
function new_unittest(name, test) result(u)
character(len=*), intent(in) :: name
procedure(test_interface) :: test
type(unittest_type) :: u
u%name = name
u%test => test
end function new_unittest
end module td_mre