[Fortran-Experiments] Merge to r120360
Tobias Burnus
burnus@net-b.de
Wed Feb 21 22:47:00 GMT 2007
Hi,
Christopher D. Rickett wrote:
>> gfortran compiles the following without any error/warning:
>> -----------------------
>> subroutine var bind(c)
>> end subroutine var
>> -----------------------
>> I think this is invalid and one needs to add a "()", i.e. "subroutine
>> var () bind(c)". (cf. R1232 in "12.5.2.2 Subroutine subprogram").
> i didn't think that this was an error. the syntax rule for
> subroutine-stmt and constraints listed in the annex D didn't specify
> that the parens are required if you have bind(c) (at least not that i
> see). do you know of a location where the standard makes the requirement?
Yes, R1232 in 12.5.2.2; you need to follow the "[ ]":
R1232
subroutine-stmt is [ prefix ]
SUBROUTINE subroutine-name
[ ( [ dummy-arg-list ] ) [ proc-language-binding-spec ] ]
That is: The () are required if "proc-language-binding-spec" is present.
I found another bunch of small problems:
-----------------------------------
module x
use iso_c_binding
contains
function foo() bind(c,name="xx")
integer(c_int),bind(c,name="xy") :: foo
! NAG f95: "BIND(C) for non-variable FOO"
! g95: "Duplicate BIND attribute specified"
! gfortran: Accepted
foo = 5_c_int
end function foo
function test()
integer(c_int) :: test
bind(c,name="kk") :: test
! NAG f95: "BIND(C) for non-variable TEST"
! gfortran, g95: Accepted
test = 5_c_int
end function test
function bar() bind(c)
integer(c_int) :: bar
bind(c,name="zx") :: bar
bar = 5_c_int
end function bar
end module x
-----------------------------------
foo and test should be clear.
For "bar", this error is ok:
Error: Variable 'bar' already declared as bind(c) at (1)
However, I don't understand the error:
Error: Unexpected junk in formal argument list at (1)
Tobias
More information about the Fortran
mailing list