Procedure Pointers: a first patch

Janus Weil jaydub66@googlemail.com
Fri May 23 20:50:00 GMT 2008


Hi freaks,

here goes another update to my procptr patch, taking care of the
following items in Tobi's list:

> ! rejects-valid:
>
> intrinsic sin
> procedure(real), pointer :: a
> a => sin ! Error: Function 'sin' requires an argument list at (1)
> end
>
> ! ice-on-invalid-code:
>
> intrinsic sin
> procedure(real), pointer :: a
> a => sin(4.0) ! ICE in fold_convert, at fold-const.c:2527
> end
>
> ! rejects-valid:
>
> procedure(real), save, pointer :: a
>                                 1
> Error: PROCEDURE attribute conflicts with SAVE attribute in 'a' at (1)
>
> "C1214 If a procedure entity has the INTENT attribute or SAVE attribute, it
> shall also have the POINTER attribute."
>
> ! rejects-valid:
>
> procedure(one), pointer :: a => null()
>                             1
> Error: Initialization at (1) isn't for a pointer variable
>
> ! rejects-valid:
>
> external foo
> procedure(), pointer :: a
> a => foo
> call a()
> end
> ! Error: 'a' at (1) has a type, which is not consistent with the CALL at (2)
>
> ! rejects-valid:
>
> integer :: i, foo
> external foo
> procedure(), pointer :: a
> a => foo
> i = a()
> end
> ! Error: Can't convert PROCEDURE to INTEGER(4) at (1)

Basically all of these should work now.

The last one does compile (provided one implements foo somewhere), but
it only gives useful results if foo is declared as real, because the
return value of "a" is also real (implicitly).

One remaining problem is that the two last snippets work each on their
own, but not when combined into one single program.

I also tried to make PR32580 work, and bashed some error messages, but
now I get:

test32580.f90:(.text+0x33): undefined reference to
`__iso_c_binding_c_f_procpointer_u0'

And I don't quite see what the problem is.

Cheers,
Janus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procptr135801.diff
Type: text/x-patch
Size: 12522 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080523/f7487c21/attachment.bin>


More information about the Fortran mailing list