This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: ABSTRACT interfaces + PROCEDURE declarations
Hi Janus,
Tobias Burnus wrote:
> [E-Mail regards PROCEDURE patch only]
>
> implicit none
> procedure(REAL) :: proc
> end
>
This is by the way the same as:
real proc
external proc
> implicit none
> procedure() :: proc
> end
>
And this the same as:
external proc
An invalid program that is accepted:
module a
implicit none
interface z
subroutine foo()
end subroutine
subroutine sub(a)
integer :: a
end subroutine sub
end interface
end module a
use a
implicit none
procedure(z) :: bar
end
z is a generic interface, but "C1212 (R1215) The name shall be the name
of an abstract interface or of a procedure that has an explicit interface."
Intrinsic procedure make also trouble:
(I am not sure whether these have to be handled correctly from the
beginning, but they should either be fixed with one of the following
patches or there should be a PR for it.)
implicit none
procedure(cos) :: bar
end
gives the error:
Error: Symbol 'cos' at (1) has no IMPLICIT type
The following compiles but is invalid:
implicit none
intrinsic cos
procedure(cos) :: bar
call bar()
end
NAG f95 diagnoses:
Error: a.f90, line 4: Too few arguments in reference to BAR
The following is valid but rejected:
implicit none
intrinsic cos
procedure(cos) :: bar
print *, bar(4.4)
end
Error: Function 'bar' at (1) has no IMPLICIT type
And the following is invalid but accepted:
implicit none
intrinsic amax1
procedure(amax1) :: bar
end
NAG diagnoses:
Error: b.f90, line 3: AMAX1 is not the name of a specific intrinsic that
may be used a proc-interface
(MAX is marked with a bullet in the 13.6; cf. C1212.)
Cf. intrinsic.c and ACTUAL_NO/ACTUAL_YES.
(MAX itself would be additionally invalid as it is no specific name to
an intrinsic function as NAG f95 also diagnoses:
Error: b.f90, line 3: MAX is not a specific intrinsic function name
Error: b.f90, line 3: MAX is not the name of a specific intrinsic that
may be used a proc-interface)
For:
implicit none
intrinsic cos
procedure(cos) :: sin
print *, sin(3.3)
end
I would expect that this give a link error for "sin_", but it is
accepted. The analogous:
interface
function sin(x)
real :: sin, x
end function
end interface
print *, sin(3.3)
gives this error.
Note: "procedure(cos)" means the interface of the specific interface of
COS, i.e. only real arguments are allowed; for double precision "dcos"
has to be used.
Tobias