[4.5, Patch, Fortran] PR 36704: Procedure pointer as function result

Janus Weil jaydub66@googlemail.com
Thu Apr 9 08:15:00 GMT 2009


2009/4/8 Tobias Burnus <burnus@net-b.de>:
>
> ! compile with -std=f95
> function f()
>  intrinsic sin
>  external f
>  pointer f
>  real f
> ! ICE without the following line
> ! strange error with that line
> !  f => sin
> end function f

Good catch. Already the following should be rejected with -std=f95:

  external f
  pointer f

So I guess I will open a separate PR for this. The F95 standard does
not explicitly mention procedure pointers anywhere, and forbids a
symbol to have the EXTERNAL and POINTER attributes at the same time
(see section 5.1).


> Some tiny nit found while reading the patch:
>
>  function aux()
>    external aux
>    pointer aux
>  end function
>
> Can you add a "aux=>something" line there? I know the warning is not
> triggered as the error message for "foo" comes earlier but ...
>
> module mo
> contains
>  function j()
>    procedure(),pointer :: j
>    j => iabs
>
> Pedantically, I would add an "intrinsic iabs".

Ok, updated the test cases accordingly. I will commit the patch later
today, provided there are no further objections.

Cheers,
Janus



>> 2009-04-08  Janus Weil  <janus@gcc.gnu.org>
>>
>>       PR fortran/36704
>>       * decl.c (add_hidden_procptr_result): New function for handling
>>       procedure pointer return values by adding a hidden result variable.
>>       (variable_decl,match_procedure_decl,gfc_match_function_decl,
>>       gfc_match_subroutine,gfc_match_end,attr_decl1): Handle procedure pointer
>>       return values.
>>       * parse.c (parse_interface): Add EXTERNAL attribute only after
>>       FUNCTION/SUBROUTINE declaration is complete.
>>       * primary.c (replace_hidden_procptr_result): New function for replacing
>>       function symbol by hidden result variable.
>>       (gfc_match_rvalue,match_variable): Replace symbol by hidden result
>>       variable.
>>       * resolve.c (resolve_contained_fntype,resolve_function,resolve_variable,
>>       resolve_symbol): Allow for procedure pointer function results.
>>       (resolve_fl_procedure): Conflict detection moved here from
>>       'check_conflict'.
>>       * symbol.c (gfc_check_function_type): Allow for procedure pointer
>>       function results.
>>       (check_conflict): Move some conflict detection to resolution stage.
>>       * trans-types.c (gfc_sym_type,gfc_get_function_type): Handle hidden
>>       result variables.
>>
>>
>> 2009-04-08  Janus Weil  <janus@gcc.gnu.org>
>>
>>       PR fortran/36704
>>       * gfortran.dg/external_procedures_1.f90: Modified.
>>       * gfortran.dg/proc_ptr_result_1.f90: New.
>>       * gfortran.dg/proc_ptr_result_2.f90: New.
>>       * gfortran.dg/proc_ptr_result_3.f90: New.
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_result_1.f90
Type: text/x-fortran
Size: 2661 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090409/91e77ac1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_result_2.f90
Type: text/x-fortran
Size: 992 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090409/91e77ac1/attachment-0001.bin>


More information about the Fortran mailing list