Remaining item since PR 32580 has been fixed. Procedure pointers as function result are not yet implemented and currently rejected. Short example: function foo() result(bar) procedure() :: bar and function foo() procedure() :: foo Long example: http://groups.google.com/group/comp.lang.fortran/msg/7bddd7097fb985a5
Btw the examples in comment #0 slightly miss the point, since they lack the POINTER attribute. Correct version: function foo() result(bar) procedure(),pointer :: bar and function foo() procedure(),pointer :: foo
Created attachment 16793 [details] patch v1 Attached is a minimal patch, which makes the simple case work where a separate result variable is used, like in this example: procedure(real),pointer :: p p => foo() print *,p(1.0) contains function foo() result(bar) procedure(real),pointer :: bar bar => sin end function end
Created attachment 16795 [details] patch v2 This updated patch passes the testsuite without regressions and adds some additional checks.
Subject: Bug 36704 Author: janus Date: Tue Dec 2 11:58:16 2008 New Revision: 142351 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142351 Log: 2008-12-02 Janus Weil <janus@gcc.gnu.org> PR fortran/36704 PR fortran/38290 * decl.c (match_result): Result may be a standard variable or a procedure pointer. * expr.c (gfc_check_pointer_assign): Additional checks for procedure pointer assignments. * primary.c (gfc_match_rvalue): Bugfix for procedure pointer assignments. * resolve.c (resolve_function): Check for attr.subroutine. * symbol.c (check_conflict): Addtional checks for RESULT statements. * trans-types.c (gfc_sym_type,gfc_get_function_type): Support procedure pointers as function result. 2008-12-02 Janus Weil <janus@gcc.gnu.org> PR fortran/36704 PR fortran/38290 * gfortran.dg/entry_7.f90: Modified. * gfortran.dg/proc_ptr_2.f90: Extended. * gfortran.dg/proc_ptr_3.f90: Modified. * gfortran.dg/proc_ptr_11.f90: New. * gfortran.dg/proc_ptr_12.f90: New. * gfortran.dg/result_1.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/proc_ptr_11.f90 trunk/gcc/testsuite/gfortran.dg/proc_ptr_12.f90 trunk/gcc/testsuite/gfortran.dg/result_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/expr.c trunk/gcc/fortran/primary.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/symbol.c trunk/gcc/fortran/trans-types.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/entry_7.f90 trunk/gcc/testsuite/gfortran.dg/proc_ptr_2.f90 trunk/gcc/testsuite/gfortran.dg/proc_ptr_3.f90
Further test cases: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/e0d04d755453a2a5
Patch: http://gcc.gnu.org/ml/fortran/2009-03/msg00044.html
Subject: Bug 36704 Author: janus Date: Thu Apr 9 09:39:09 2009 New Revision: 145815 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145815 Log: 2009-04-09 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-09 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. Added: trunk/gcc/testsuite/gfortran.dg/proc_ptr_result_1.f90 trunk/gcc/testsuite/gfortran.dg/proc_ptr_result_2.f90 trunk/gcc/testsuite/gfortran.dg/proc_ptr_result_3.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/parse.c trunk/gcc/fortran/primary.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/symbol.c trunk/gcc/fortran/trans-types.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/external_procedures_1.f90
Fixed by r145815. Closing.