Dear All, The attached patch more or less implements the assignment of expressions to the result of a pointer function. To wit:
my_ptr_fcn (arg1, arg2...) = expr arg1 would usually be the target, pointed to by the function. The patch parses these statements and resolves them into: temp_ptr => my_ptr_fcn (arg1, arg2...) temp_ptr = expr I say more or less implemented because I have ducked one of the headaches here. At the end of the specification block, there is an ambiguity between statement functions and pointer function assignments. I do not even try to resolve this ambiguity and require that there be at least one other type of executable statement before these beasts. This can undoubtedly be fixed but the effort seems to me to be unwarranted at the present time. This version of the patch extends the coverage of allowed rvalues to any legal expression. Also, all the problems with error.c have been dealt with by Manuel's patch. I am grateful to Dominique for reminding me of PR40054 and pointing out PR63921. After a remark of his on #gfortran, I fixed the checking of the standard to pick up all the offending lines with F2003 and earlier. Bootstraps and regtests on FC21/x86_64 - OK for trunk? Cheers Paul 2015-09-06 Paul Thomas <pa...@gcc.gnu.org> PR fortran/40054 PR fortran/63921 * decl.c (get_proc_name): Return if statement function is found. * match.c (gfc_match_ptr_fcn_assign): New function. * match.h : Add prototype for gfc_match_ptr_fcn_assign. * parse.c : Add static flag 'in_specification_block'. (decode_statement): If in specification block match a statement function, otherwise if standard embraces F2008 try to match a pointer function assignment. (parse_interface): Set 'in_specification_block' on exiting from parse_spec. (parse_spec): Set and then reset 'in_specification_block'. (gfc_parse_file): Set 'in_specification_block'. * resolve.c (get_temp_from_expr): Extend to include other expressions than variables and constants as rvalues. (resolve_ptr_fcn_assign): New function. (gfc_resolve_code): Call resolve_ptr_fcn_assign. * symbol.c (gfc_add_procedure): Add a sentence to the error to flag up the ambiguity between a statement function and pointer function assignment at the end of the specification block. 2015-09-06 Paul Thomas <pa...@gcc.gnu.org> PR fortran/40054 PR fortran/63921 * gfortran.dg/fmt_tab_1.f90: Change from run to compile and set standard as legacy. * gfortran.dg/ptr_func_assign_1.f08: New test. * gfortran.dg/ptr_func_assign_2.f08: New test.