From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 350E73858D39 for ; Thu, 5 Jan 2023 21:14:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 350E73858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1672953255; bh=heIQI/oGOSbtcJDScFhIUxhS6rXVxhaSpd9s1/mzgL8=; h=X-UI-Sender-Class:From:To:Subject:Date:References; b=qerL3Qe9U3aDJ1ZJ/0+E4gR+mcNfOmzjtMn3KmvKOGXwNc3qEpfzO2Xn6KXvYaabM dmuv1DJE4Ga5T57GfqnWeZdPi8MVXMBVKiAv+ysUPRlEy+uoPKHIjjK2NM5YXH+dNH YKbAGArcWHBIaWMDdNPUqiRoUwqYQJ+jz7OekhvRXEzqn1uo2ajoaws0SaK2+I78lk KwvVYD1AFa5SGePEl9A9OK4fkjoH7PlJeD3vsRPUcmf1Q47458h8Wbw5E2mG1eVAo9 R/ikOgmDa7SAmRCFPjHDcsbZOips9PHybZyk2zYSkzo8EIrz1VD70oRtsvmTP7z022 CA+bQMyZeF9PA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.83.244] ([93.207.83.244]) by web-mail.gmx.net (3c-app-gmx-bap19.server.lan [172.19.172.89]) (via HTTP); Thu, 5 Jan 2023 22:14:15 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran Subject: Fw: Re: [Patch, fortran] PR37336 (Finalization) - [F03] Finish derived-type finalization Content-Type: text/plain; charset=UTF-8 Date: Thu, 5 Jan 2023 22:14:15 +0100 Importance: normal Sensitivity: Normal References: <9a2667e2-8055-bcac-1862-05c8ac60ce7a@gmx.de> <3cbaf568-84ac-8498-558f-9560fe395d66@gmx.de> <7ab973cd-f62e-28be-36e8-4e44252a4a38@gmx.de> <061aee5b-c27c-3a9f-419d-9893c2d744c4@netcologne.de> Content-Transfer-Encoding: quoted-printable X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:+ts2GNaklPExUE640jlkJqWZTt5szVzu8RjYOGBbSAMtvs41hiBzylz/r8kIZqhzYHF2L qb9+IWMW1ZS+3wvLd5YvHcQScpQM5gR5tTtpYLZyaRRc6v+hY3NFsgwwboVe9XbySbeyxuOIn2w4 tUroDrrDvwVGYcIWoa61PqUpvOgYEeRbI6O+XgxtWNnbqj4Cyv6EPg0faf469vULXnTBdWxWm85S k86XQyYeSXRyoXV1tG5zvuRBzuFdnobIri1GWMrHkqEZSoQB6wMOjyPhvscYtEZPdx4Kh+zbs+ra KM= UI-OutboundReport: notjunk:1;M01:P0:pNSVn0HryOA=;JJvG7UacQ3ExPz2uIC2Fy44kjIj 5eBNPotjbGk3aYAmk6t/jLIiOcCWLHHQcZl5qG+rAeFigL4w1ZAPd6NNSjRHvhlVr1cBDhGMQ 8NzygXgPdmm2JLZyBELwHr76l8XM9RrLOPBnENW4bzXxmDkpzwgHZyJUnz0VoYR/rVP/A88fY V44w/eIE51iQUV64w7kFlMbxPsVvYbIMPw1FoD+ImpQ5lPf9kauf2Kwe1LNc4vepZBITS87ky gCj6cL8nPnf0cpqST11921I6VkXAXORJuU2b6hIy9F4lS8p0RSQp5lM9llGXft0HtkH29ImA9 7smS+U1Q6MJut55Tjt6ehSJ+pIpTWTrRo3k0eJn4KmXJJFHe5xaEb1hhmhGXNFUmAMGfDyJuu ISq6FBro3JjQCmjtSSS9iEibRi/LvumV7K4Gr5ZytYqXjSQFbK3IwjFVh6qvaVhcsCg/6w8fz 5TtdHY/9IYUACn764XYlztB4FoORlBUxOn+6q2PPJuc6MAprJHrFEtRKDk1y1OVwqwucpHZFC ybto+zVgAHW1PMTT1F6wjlmRWS+f24YJV7rQGUTUbm+UH1zlMIFh095FBunOjMluSsmhS97d3 IJ28XwuKK0JL4giSZ9sPn6h/xGC7FnyTBQwzMioKIQawtNsQO89Iu38NpaU/C4fdi18NvraU8 rJqZjJYOzi2I1qlLSDTyTwG7/2gU6UNII24O8usyoEoK+8tLkzj227Qex/EWgEmE8FEmBEmls X7uCZfuQXvi6px/qHIq+7domBFfjEq63PDAJnkdcrr5G+ZuiV/AqpX/ugHDcUrgJ67PMnEpom aQLydEaD168lBZNb4Zgfntml+39O/VTN6BTqUq8cH8CJs= X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Resending as plain text, as the original version did not appear on the fort= ran list=2E=2E=2E =C2=A0 Gesendet:=C2=A0Donnerstag, 05=2E Januar 2023 um 22:10 Uhr Von:=C2=A0"Harald Anlauf" An:=C2=A0"Paul Richard Thomas" Cc:=C2=A0"fortran@gcc=2Egnu=2Eorg" , "Alessandro = Fanfarillo" , "Andrew Benson" , "Thomas Koenig" , "Damian= Rouson" Betreff:=C2=A0Re: [Patch, fortran] PR37336 (Finalization) - [F03] Finish d= erived-type finalization Dear Paul, all, =C2=A0 I had a first look at the patch and the testcases, and I really look forwa= rd to getting this into gfortran=2E =C2=A0 A few questions surfaced when playing with it, which is why am asking for = others to comment=2E =C2=A0 Testcase finalize_38=2Ef90 exhibits a (potential) discrepancy to my expect= ions when playing with options -std=3Df2018 and -std=3Dgnu (the default)=2E =C2=A0 What is the expected behavior of -std=3Dgnu?=C2=A0 My expectation is that = -std=3Dgnu always corresponds to the latest implemented standard (currently= F2018), except for possibly allowing for GNU-extensions=2E=C2=A0 This migh= t imply that corrigenda to a standard or a newer version may lead (over tim= e) to an adjustment of the behavior=2E=C2=A0 Any opinions on it?=C2=A0 Do w= e need to always test (in the testsuite) for compliance with older standard= s? =C2=A0 If there is a change in the behavior between versions of the standard: sho= uld the compiler give a warning, when, and if so, is there a preferred flag= that should control that warning (-pedantic or rather -Wsurprising or what= ever)? =C2=A0 Thanks, Harald =C2=A0 Gesendet:=C2=A0Montag, 02=2E Januar 2023 um 14:15 Uhr Von:=C2=A0"Paul Richard Thomas" An:=C2=A0"fortran@gcc=2Egnu=2Eorg" Cc:=C2=A0"Harald Anlauf" , "Alessandro Fanfarillo" , "Andrew Benson" , "Thomas Koenig" , "Damian Rouson" Betreff:=C2=A0[Patch, fortran] PR37336 (Finalization) - [F03] Finish deriv= ed-type finalization Hi All, =C2=A0 Happy new year! =C2=A0 This thread broke off in February last year, as did my effort to resolve a= ll the issues=2E However, prodded by Damian, I picked up the mantle again a= bout a month ago=2E =C2=A0 Please consider this posting to be a placeholder=2E All the dependencies o= f PR37366 appear to be fixed although some minor issues remain and some div= ergences with the other brands=2E I will be contacting the vendors of the o= ther brands today or tomorrow and will try to achieve some resolution with = them=2E In the meantime, I will break the patch down to half a dozen more d= igestible chunks and will aim to submit formally in a week or so=2E =C2=A0 Of the remaining issues: Function results of finalizable type with zero components confound the gim= plifier: see PR65347 comment 3=2E finalize_38=2Ef90 loses 38 bytes in 4 blocks and has a load of invalid wri= tes=2E finalize_49=2Ef90 has a number of invalid writes=2E =C2=A0 Please give the patch a whirl and any feedback that you might have would b= e very welcome=2E =C2=A0 Cheers =C2=A0 Paul =C2=A0 Fortran:Implement missing finalization features [PR37336] 2022-02-02 =C2=A0Paul Thomas =C2=A0 gcc/fortran PR fortran/103854 * class=2Ecc (has_finalizer_component): Do not return true for procedure pointer components=2E PR fortran/96122 * class=2Ecc (finalize_component): Include the missing arguments in the call to the component's finalizer wrapper=2E PR fortran/37336 * class=2Ecc (finalizer_insert_packed_call): Remove the redundant argument in the call to the final subroutine=2E (generate_finalization_wrapper): Add support for assumed rank finalizers=2E (gfc_may_be_finalized): New helper function=2E * dump_parse_tree=2Ecc (show_expr): Mark expressions with must_finalize set=2E * gfortran=2Eh : Add prototype for gfc_may_be_finalized=2E * resolve=2Ecc (resolve_where, gfc_resolve_where_code_in_forall, gfc_resolve_forall_body, gfc_resolve_code): Check that the op code is still EXEC_ASSIGN=2E If it is set lhs to must finalize=2E (generate_component_assignments): Set must_finalize if needed=2E (gfc_resolve_finalizers): Error if assumed rank finalizer is not the only one=2E Warning on lack of scalar finalizer modified to account for assumed rank finalizers=2E (resolve_symbol): Set referenced an unreferenced symbol that will be finalized=2E * trans-array=2Ecc (gfc_trans_array_constructor_value): Add code to finalize the constructor result=2E Warn that this feature was removed in F2018 and that it is suppressed by -std=3D2018=2E (trans_array_constructor): Add finalblock, pass to previous and apply to loop->post if filled=2E (gfc_add_loop_ss_code): Add se finalblock to outer loop post=2E (gfc_trans_array_cobounds, gfc_trans_array_bounds): Add any generated finalization code to the main block=2E (structure_alloc_comps): Add boolean argument to suppress finalization and use it for calls from gfc_deallocate_alloc_comp_no_caf=2E Otherwise it defaults to false=2E Add a second, additional boolean argument to nullify pointer components and use it in gfc_copy_alloc_comp_del_ptrs=2E (gfc_copy_alloc_comp_del_ptrs): New wrapper for structure_alloc_comps=2E (gfc_alloc_allocatable_for_assignment): Suppress finalization by setting new arg in call to gfc_deallocate_alloc_comp_no_caf=2E (gfc_trans_deferred_array): Use gfc_may_be_finalized=2E * trans-array=2Eh : Add the new boolean argument to the prototype of gfc_deallocate_alloc_comp_no_caf with a default of false=2E Add prototype for gfc_copy_alloc_comp_del_ptrs=2E * trans-decl=2Ecc (gfc_get_symbol_decl): Make sure that temporary variables from resolve=2Ecc are not finalized by detection of a leading '_' in the symbol name=2E (init_intent_out_dt): Tidy up the code=2E * trans-expr=2Ecc (gfc_init_se): Initialize finalblock=2E (finalize_function_result): New function that finalizes function results in the correct order=2E (gfc_conv_procedure_call): Use new function for finalizable function results=2E Replace in-line block for class results with call to new function=2E (gfc_conv_expr): Finalize structure constructors for F2003 and F2008=2E Warn that this feature was deleted in F2018 and, unlike array constructors, is not default=2E Add array constructor finalblock to the post block=2E (gfc_trans_scalar_assign): Suppress finalization by setting new argument in call to gfc_deallocate_alloc_comp_no_caf=2E Add the finalization blocks to the main block=2E (gfc_assignment_finalizer_call): New function to provide finalization on intrinsic assignment=2E (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=2E (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=2E * trans-io=2Ecc (gfc_trans_transfer): Add the final block=2E * trans-stmt=2Ecc (gfc_trans_call, gfc_trans_allocate): likewise=2E * trans=2Eh: Add finalblock to gfc_se=2E Add the prototype for gfc_finalize_function_result=2E gcc/testsuite/ PR fortran/64290 * gfortran=2Edg/finalize_38=2Ef90 : New test=2E * gfortran=2Edg/allocate_with_source_25=2Ef90 : The number of final calls goes down from 6 to 4=2E * gfortran=2Edg/unlimited_polymorphic_8=2Ef90 : Tree dump reveals foo=2E1=2Ex rather than foo=2E0=2Ex PR fortran/67444 * gfortran=2Edg/finalize_39=2Ef90 : New test=2E PR fortran/67471 * gfortran=2Edg/finalize_40=2Ef90 : New test=2E PR fortran/69298 PR fortran/70863 * gfortran=2Edg/finalize_41=2Ef90 : New test=2E PR fortran/71798 * gfortran=2Edg/finalize_42=2Ef90 : New test=2E PR fortran/80524 * gfortran=2Edg/finalize_43=2Ef90 : New test=2E PR fortran/82996 * gfortran=2Edg/finalize_44=2Ef90 : New test=2E PR fortran/84472 * gfortran=2Edg/finalize_45=2Ef90 : New test=2E PR fortran/88735 PR fortran/93691 * gfortran=2Edg/finalize_46=2Ef90 : New test=2E PR fortran/91316 * gfortran=2Edg/finalize_47=2Ef90 : New test=2E PR fortran/106576 * gfortran=2Edg/finalize_48=2Ef90 : New test=2E PR fortran/91316 * gfortran=2Edg/finalize_47=2Ef90 : New test=2E =C2=A0 =C2=A0 =C2=A0 =C2=A0