[J3] Is this standard-conforming?
Bill Long
longb at cray.com
Thu Jul 26 12:23:21 EDT 2018
Hi Damian,
I’m guessing that this program does compile :
program main
implicit none
type ugg
integer :: n
end type ugg
interface
type(ugg) function foo()
import ugg
end function foo
end interface
end program
Similar to your case, the import of ugg from the host occurs on the statement after the one where ugg is used. In the case of a type definition like this there is no practical alternative, so compilers have been taught to ‘look ahead’ for a type definition. I suspect we intended to allow the case you described, but the vendors did not anticipate needing to do a look-ahead for anything other that the function type. If Malcolm disagrees about the intent, I’m ok with that. I think it boils down to whether the FUNCTION statement itself is part of the scoping unit of the function.
Cheers,
Bill
> On Jul 26, 2018, at 5:12 AM, Damian Rouson via J3 <j3 at mailman.j3-fortran.org> wrote:
>
> One processor accepts the code below. Three others generate error messages related to the binding label c_name and either report a syntax error or report that the binding label is a variable that does not reduce to a constant expression.
>
> Damian
>
> program main
> implicit none
>
> character(len=5), parameter :: c_name="c_foo"
>
> interface
> subroutine foo() bind(C,name=c_name)
> import c_name
> end subroutine
> end interface
>
> call foo()
>
> end program
>
Bill Long longb at cray.com
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
More information about the J3
mailing list