(j3.2006) EXTERNAL statement in an INTERFACE body
Cohen Malcolm
malcolm
Thu Apr 14 04:09:51 EDT 2016
The code does not make sense, so no it is not valid.
>The interface body confers the EXTERNAL
>attribute within the containing scoping unit, and the EXTERNAL statement
>confers the EXTERNAL attribute within the interface body.
Right, which because declarations using the eponymous result name apply to the result, means that this function ***returns a procedure***. Not a procedure pointer, but an actual procedure. Obviously this does not make sense ? no interpretation is established for such a concept.
>So, you are saying that the function statement in the interface body does not confer the EXTERNAL attribute on EXT1 in the interface body?
Correct, inside the interface body it is the eponymous result (and usually a variable, though it can be a procedure pointer). But it cannot be a procedure, so ?Conflicting attributes? is a good error message.
With the slightly different example,
subroutine s
external s
one would deduce that the SUBROUTINE statement confers the external attribute not just outside the scoping unit, but inside as well, since use of the procedure name refers to the procedure (enabling direct recursion, or passing as an actual argument, when appropriate).
Cheers,
From: Daniel C Chen
Sent: Thursday, April 14, 2016 3:53 AM
To: j3 at mailman.j3-fortran.org
Subject: (j3.2006) EXTERNAL statement in an INTERFACE body
Hello all,
Is the following code valid?
program main
real ext, inval
interface
function ext1 (y)
real ext1, y
external ext1
end function ext1 ! Duplicate EXTERNAL attribute
end interface
inval = 1.0
print *, ext1(inval)
end program main
The EXTERNAL statement is allowed inside an interface body. However, we have a constraint as:
[16-007: p118] C542 In an external subprogram, the EXTERNAL attribute shall not be specified for a procedure defined by the subprogram.
It only mentions 'external subprogram'. Should it also include interface body to be consistent?
Thanks,
Daniel
XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________
--------------------------------------------------------------------------------
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
--
........................Malcolm Cohen, Nihon NAG, Tokyo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20160414/c08f523e/attachment.html
More information about the J3
mailing list