public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>
Subject: Fw: Re: [Patch, fortran] PR37336 (Finalization) - [F03] Finish derived-type finalization
Date: Thu, 5 Jan 2023 22:14:15 +0100	[thread overview]
Message-ID: <trinity-df6b63da-06ae-4443-aa7a-decdca3e9b0a-1672953255600@3c-app-gmx-bap19> (raw)
In-Reply-To: <trinity-a4069639-4079-4f60-b928-1fec82384b1e-1672953005015@3c-app-gmx-bap48>

Resending as plain text, as the original version did not appear on the fortran list...
 

Gesendet: Donnerstag, 05. Januar 2023 um 22:10 Uhr
Von: "Harald Anlauf" <anlauf@gmx.de>
An: "Paul Richard Thomas" <paul.richard.thomas@gmail.com>
Cc: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>, "Alessandro Fanfarillo" <alessandro.fanfarillo@gmail.com>, "Andrew Benson" <abenson@carnegiescience.edu>, "Thomas Koenig" <tkoenig@gcc.gnu.org>, "Damian Rouson" <damian@archaeologic.codes>
Betreff: Re: [Patch, fortran] PR37336 (Finalization) - [F03] Finish derived-type finalization

Dear Paul, all,
 
I had a first look at the patch and the testcases, and I really look forward to getting this into gfortran.
 
A few questions surfaced when playing with it, which is why am asking for others to comment.
 
Testcase finalize_38.f90 exhibits a (potential) discrepancy to my expections when playing with options -std=f2018 and -std=gnu (the default).
 
What is the expected behavior of -std=gnu?  My expectation is that -std=gnu always corresponds to the latest implemented standard (currently F2018), except for possibly allowing for GNU-extensions.  This might imply that corrigenda to a standard or a newer version may lead (over time) to an adjustment of the behavior.  Any opinions on it?  Do we need to always test (in the testsuite) for compliance with older standards?
 
If there is a change in the behavior between versions of the standard: should the compiler give a warning, when, and if so, is there a preferred flag that should control that warning (-pedantic or rather -Wsurprising or whatever)?
 

Thanks,
Harald
 

Gesendet: Montag, 02. Januar 2023 um 14:15 Uhr
Von: "Paul Richard Thomas" <paul.richard.thomas@gmail.com>
An: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>
Cc: "Harald Anlauf" <anlauf@gmx.de>, "Alessandro Fanfarillo" <alessandro.fanfarillo@gmail.com>, "Andrew Benson" <abenson@carnegiescience.edu>, "Thomas Koenig" <tkoenig@gcc.gnu.org>, "Damian Rouson" <damian@archaeologic.codes>
Betreff: [Patch, fortran] PR37336 (Finalization) - [F03] Finish derived-type finalization

Hi All,
 
Happy new year!
 
This thread broke off in February last year, as did my effort to resolve all the issues. However, prodded by Damian, I picked up the mantle again about a month ago.
 
Please consider this posting to be a placeholder. All the dependencies of PR37366 appear to be fixed although some minor issues remain and some divergences with the other brands. I will be contacting the vendors of the other brands today or tomorrow and will try to achieve some resolution with them. In the meantime, I will break the patch down to half a dozen more digestible chunks and will aim to submit formally in a week or so.
 
Of the remaining issues:
Function results of finalizable type with zero components confound the gimplifier: see PR65347 comment 3.
finalize_38.f90 loses 38 bytes in 4 blocks and has a load of invalid writes.
finalize_49.f90 has a number of invalid writes.
 
Please give the patch a whirl and any feedback that you might have would be very welcome.
 
Cheers
 
Paul
 
Fortran:Implement missing finalization features [PR37336]

2022-02-02  Paul Thomas  <pault@gcc.gnu.org[mailto:pault@gcc.gnu.org]>

gcc/fortran
PR fortran/103854
* class.cc (has_finalizer_component): Do not return true for
procedure pointer components.

PR fortran/96122
* class.cc (finalize_component): Include the missing arguments
in the call to the component's finalizer wrapper.

PR fortran/37336
* class.cc (finalizer_insert_packed_call): Remove the redundant
argument in the call to the final subroutine.
(generate_finalization_wrapper): Add support for assumed rank
finalizers.
(gfc_may_be_finalized): New helper function.
* dump_parse_tree.cc (show_expr): Mark expressions with
must_finalize set.
* gfortran.h : Add prototype for gfc_may_be_finalized.
* resolve.cc (resolve_where, gfc_resolve_where_code_in_forall,
gfc_resolve_forall_body, gfc_resolve_code): Check that the op
code is still EXEC_ASSIGN. If it is set lhs to must finalize.
(generate_component_assignments): Set must_finalize if needed.
(gfc_resolve_finalizers): Error if assumed rank finalizer is
not the only one. Warning on lack of scalar finalizer modified
to account for assumed rank finalizers.
(resolve_symbol): Set referenced an unreferenced symbol that
will be finalized.
* trans-array.cc (gfc_trans_array_constructor_value): Add code
to finalize the constructor result. Warn that this feature was
removed in F2018 and that it is suppressed by -std=2018.
(trans_array_constructor): Add finalblock, pass to previous
and apply to loop->post if filled.
(gfc_add_loop_ss_code): Add se finalblock to outer loop post.
(gfc_trans_array_cobounds, gfc_trans_array_bounds): Add any
generated finalization code to the main block.
(structure_alloc_comps): Add boolean argument to suppress
finalization and use it for calls from
gfc_deallocate_alloc_comp_no_caf. Otherwise it defaults to
false. Add a second, additional boolean argument to nullify
pointer components and use it in gfc_copy_alloc_comp_del_ptrs.
(gfc_copy_alloc_comp_del_ptrs): New wrapper for
structure_alloc_comps.
(gfc_alloc_allocatable_for_assignment): Suppress finalization
by setting new arg in call to gfc_deallocate_alloc_comp_no_caf.
(gfc_trans_deferred_array): Use gfc_may_be_finalized.
* trans-array.h : Add the new boolean argument to the prototype
of gfc_deallocate_alloc_comp_no_caf with a default of false.
Add prototype for gfc_copy_alloc_comp_del_ptrs.
* trans-decl.cc (gfc_get_symbol_decl): Make sure that temporary
variables from resolve.cc are not finalized by detection of a
leading '_' in the symbol name.
(init_intent_out_dt): Tidy up the code.
* trans-expr.cc (gfc_init_se): Initialize finalblock.
(finalize_function_result): New function that finalizes
function results in the correct order.
(gfc_conv_procedure_call): Use new function for finalizable
function results. Replace in-line block for class results with
call to new function.
(gfc_conv_expr): Finalize structure constructors for F2003 and
F2008. Warn that this feature was deleted in F2018 and, unlike
array constructors, is not default. Add array constructor
finalblock to the post block.
(gfc_trans_scalar_assign): Suppress finalization by setting new
argument in call to gfc_deallocate_alloc_comp_no_caf. Add the
finalization blocks to the main block.
(gfc_assignment_finalizer_call): New function to provide
finalization on intrinsic assignment.
(gfc_trans_arrayfunc_assign): Use the previous and ensure that
finalization occurs after the evaluation of the rhs but must
use the initial value for the lhs.
(trans_class_assignment, gfc_trans_assignment_1): Call it and
add the block between the rhs evaluation and any reallocation
on assignment that there might be.
* trans-io.cc (gfc_trans_transfer): Add the final block.
* trans-stmt.cc (gfc_trans_call, gfc_trans_allocate): likewise.
* trans.h: Add finalblock to gfc_se. Add the prototype for
gfc_finalize_function_result.

gcc/testsuite/
PR fortran/64290
* gfortran.dg/finalize_38.f90 : New test.
* gfortran.dg/allocate_with_source_25.f90 : The number of final
calls goes down from 6 to 4.
* gfortran.dg/unlimited_polymorphic_8.f90 : Tree dump reveals
foo.1.x rather than foo.0.x

PR fortran/67444
* gfortran.dg/finalize_39.f90 : New test.

PR fortran/67471
* gfortran.dg/finalize_40.f90 : New test.

PR fortran/69298
PR fortran/70863
* gfortran.dg/finalize_41.f90 : New test.

PR fortran/71798
* gfortran.dg/finalize_42.f90 : New test.

PR fortran/80524
* gfortran.dg/finalize_43.f90 : New test.

PR fortran/82996
* gfortran.dg/finalize_44.f90 : New test.

PR fortran/84472
* gfortran.dg/finalize_45.f90 : New test.

PR fortran/88735
PR fortran/93691
* gfortran.dg/finalize_46.f90 : New test.

PR fortran/91316
* gfortran.dg/finalize_47.f90 : New test.

PR fortran/106576
* gfortran.dg/finalize_48.f90 : New test.

PR fortran/91316
* gfortran.dg/finalize_47.f90 : New test.
 
 
 
 

  parent reply	other threads:[~2023-01-05 21:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 17:14 Paul Richard Thomas
2022-02-07 21:09 ` Harald Anlauf
2022-02-07 21:09   ` Harald Anlauf
2022-02-08 11:22   ` Paul Richard Thomas
2022-02-08 18:29     ` Harald Anlauf
2022-02-08 18:29       ` Harald Anlauf
2022-02-09  2:35       ` Jerry D
2022-02-10 12:25       ` Paul Richard Thomas
2022-02-10 19:49         ` Harald Anlauf
2022-02-10 19:49           ` Harald Anlauf
2022-02-11  2:15           ` Jerry D
2022-02-11  9:08           ` Paul Richard Thomas
2022-02-11 21:08             ` Harald Anlauf
2022-02-11 21:08               ` Harald Anlauf
2022-02-11 21:59               ` Paul Richard Thomas
2022-02-16 18:49                 ` Paul Richard Thomas
2022-02-17 20:55                   ` Harald Anlauf
2022-02-17 20:55                     ` Harald Anlauf
2022-02-17 21:23                   ` Thomas Koenig
2022-02-18 18:06                     ` Paul Richard Thomas
2023-01-02 13:15                       ` Paul Richard Thomas
     [not found]                         ` <trinity-a4069639-4079-4f60-b928-1fec82384b1e-1672953005015@3c-app-gmx-bap48>
2023-01-05 21:14                           ` Harald Anlauf [this message]
2023-01-06  3:08                             ` Fw: " Jerry D
2023-01-06  8:33                               ` Harald Anlauf
2023-01-07 10:57                                 ` Paul Richard Thomas
2023-01-07 15:28                                   ` Thomas Koenig
2023-01-07 18:35                                     ` Paul Richard Thomas
2023-01-08 12:03                                       ` Thomas Koenig
2023-01-08 13:42                                         ` Paul Richard Thomas
2023-01-09 20:42                                   ` Aw: " Harald Anlauf
2023-01-11 20:56                                     ` Harald Anlauf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-df6b63da-06ae-4443-aa7a-decdca3e9b0a-1672953255600@3c-app-gmx-bap19 \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).