From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by sourceware.org (Postfix) with ESMTPS id C2FA43858D35 for ; Tue, 4 Jul 2023 19:37:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2FA43858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr Received: from [192.168.1.16] ([86.215.161.51]) by smtp.orange.fr with ESMTPA id Glpiqi4YeL1SxGlpiqiA1o; Tue, 04 Jul 2023 21:37:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1688499427; bh=39UQKQHAKyN94rgT7ivvJxRCVL0NMgFaik4SNLVCSjo=; h=Date:Subject:To:References:From:In-Reply-To; b=bxeYZnRgoSbU9pRf0W0t/F5KOmBC/jji5A6oVmgtW4shyxS/lADUy3omYgZrkv09x q4XK29TsYGnNRoWDj+MS6a18WyV4EQ1Ejwhx0e6jexWUbITJc0leK6r2sR++xQKwBN Ciflk9Hg2N13p17Yn23YarxItZaFpuAom79/q5tyZyLedC9kDvCHfafzpYQSpAXcrV JYjlHr7OazvzowE/PyTQp8tHTneoqmec7Owd/sKt9iSDauF25puAuB9DUUDc7kxF9p Wk4HV0I3c7/r1+WZnbvFC5nk5eDSPSgOktz/OX/1NIzT5mcc1ZRfxUpsP1hZmwkxxN /959B7r0xf60Q== X-ME-Helo: [192.168.1.16] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Tue, 04 Jul 2023 21:37:07 +0200 X-ME-IP: 86.215.161.51 Message-ID: <3e31cc66-b7ae-adb0-f1a8-18b8bcc11c46@orange.fr> Date: Tue, 4 Jul 2023 21:37:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] Fortran: fixes for procedures with ALLOCATABLE,INTENT(OUT) arguments [PR92178] Content-Language: en-US To: Harald Anlauf , fortran , gcc-patches References: <5a5306ae-0db1-c7e2-e744-a3beced17636@orange.fr> <3adc2904-9876-74d6-2b5d-3cc1896866c3@gmx.de> From: Mikael Morin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,JMQ_SPF_NEUTRAL,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Le 04/07/2023 à 21:00, Harald Anlauf a écrit : > Hi Mikael, all, > > I think I've found it: there is a call to gfc_conv_class_to_class > that - according to a comment - does a repackaging to a class array. > Deferring that repackaging along with the deallocation not only fixes > the regression, but also the cases I tested. > > Attached is a "sneak preview", hoping that the experts (Paul, Mikael, > ...) can tell if I am going down the wrong road. > I think that's it mostly. There is one last thing that I am not sure... > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc > index 16e8f037cfc..a68c8d33acc 100644 > --- a/gcc/fortran/trans-expr.cc > +++ b/gcc/fortran/trans-expr.cc > @@ -6858,6 +6860,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, > && e->symtree->n.sym->attr.optional, > CLASS_DATA (fsym)->attr.class_pointer > || CLASS_DATA (fsym)->attr.allocatable); > + > + /* Defer repackaging after deallocation. */ > + if (defer_repackage) > + gfc_add_block_to_block (&dealloc_blk, &parmse.pre); > } > else > { ... whether you will not be deferring too much here. That is parmse.pre contains both the argument evaluation and the class container setup from gfc_conv_class_to_class. If it's safe to defer both, that's fine, otherwise a separate gfc_se struct should be passed to gfc_conv_class_to_class so that only the latter part can be deferred. Need to think of an example...