public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR40054 and PR63921 - Implement pointer function assignment - redux
@ 2015-09-06 16:40 Paul Richard Thomas
  2015-09-06 17:21 ` Paul Richard Thomas
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Richard Thomas @ 2015-09-06 16:40 UTC (permalink / raw)
  To: Dominique Dhumieres, fortran, gcc-patches

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  <pault@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  <pault@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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-09-28 21:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-06 16:40 [Patch, fortran] PR40054 and PR63921 - Implement pointer function assignment - redux Paul Richard Thomas
2015-09-06 17:21 ` Paul Richard Thomas
2015-09-17 13:51   ` Mikael Morin
2015-09-18  8:39     ` Paul Richard Thomas
2015-09-25 12:44       ` Paul Richard Thomas
2015-09-25 20:11         ` Mikael Morin
2015-09-28 19:04           ` Paul Richard Thomas
2015-09-28 22:10             ` Paul Richard Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).