The code below compiles with gfortran, but fails to compile with flang.
module foo_mod
use, intrinsic :: iso_fortran_env
use, intrinsic :: iso_c_binding
implicit none
interface new_foo
procedure :: foo_ctor
end interface
contains
function foo_ctor(options) result(retval)
implicit none
integer, intent(in) :: options
integer :: retval
interface
subroutine new_foo(f, opt) bind(c, name='new_foo')
import
implicit none
integer, intent(inout) :: f
integer(c_int), intent(in) :: opt
end subroutine
end interface
call new_foo(retval, options)
end function
end module
With flang, the error that is raised is:
error: Cannot call function 'new_foo' like a subroutine
call new_foo(retval, options)
^^^^^^^
foo.f90:14:13: Declaration of 'new_foo'
interface new_foo
^^^^^^^
This code is derived from an application used within our organization. A more complete reproducer (containing a main function, the C++ codefor new_foo and a cmake script is attached).
flang_interface_scope_reproducer.tar.gz
MD5 for attachment: 6931ab65231672d1bc51ce39095243ae