From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by sourceware.org (Postfix) with ESMTPS id 657D23858C50 for ; Sat, 22 Apr 2023 15:17:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 657D23858C50 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.15] ([86.215.161.51]) by smtp.orange.fr with ESMTPA id qEzSpghWvEVgjqEzSphPiV; Sat, 22 Apr 2023 17:17:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1682176651; bh=/FW3VNpUidAm8JMTBb3UVIyomsTFXuj6XCcJlEv02nA=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=QoBAagEnXZh9Ge+uAF598j/9ByGzojaIcGy+9cc54YHZJ2bdk5cjRcwMDZX5lGZPW Gxn4gRDETwWSlyDE9bQqXgTh+EGWWaTfRBlwoVPQED/OgT2O15KN5hpdloVfYVc+8L 4rNzDJPI/AckQjcWQo4NhRP/DsLqmLXIPsUOPTGe1eyJte567npqhgHydCgtjVK6sd 0DVDfc7e9yIPrmiqZNkQtZq6QfT73D0nRkAnQNQS1Axi6/cQM+15lR/UyG23kkZVN4 B5cpoIO4kgiNlTR5WMD+O6QuYejFz451FPHvpJE+23EgNgTcTewdoF0WgupjTA/ekC f2hTtxspmueEw== X-ME-Helo: [192.168.1.15] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Sat, 22 Apr 2023 17:17:31 +0200 X-ME-IP: 86.215.161.51 Message-ID: Date: Sat, 22 Apr 2023 17:17:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] Fortran: function results never have the ALLOCATABLE attribute [PR109500] Content-Language: en-US To: sgk@troutmask.apl.washington.edu Cc: Harald Anlauf , fortran , gcc-patches , kargl@gcc.gnu.org References: <311f891f-8fe7-72d3-de38-1b0910aed02c@orange.fr> From: Mikael Morin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,JMQ_SPF_NEUTRAL,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 22/04/2023 à 15:52, Steve Kargl a écrit : > On Sat, Apr 22, 2023 at 11:25:41AM +0200, Mikael Morin wrote: >> >> Le 20/04/2023 à 22:01, Harald Anlauf via Fortran a écrit : >>> Dear all, >>> >>> Fortran 2018 added a clarification that the *result* of a function >>> whose result *variable* has the ALLOCATABLE attribute is a *value* >>> that itself does not have the ALLOCATABLE attribute. >>> >>> For those interested: there was a thread on the J3 mailing list >>> some time ago (for links see the PR). >>> >>> The patch which implements a related check was co-authored with >>> Steve and regtested by him. Testcase verified against NAG. >>> >>> OK for mainline (gcc-14)? >>> >> Looks good in principle, but I think the real fix should be in the >> gfc_expr_attr function, which copies all the attributes (including >> allocatable) in the EXPR_FUNCTION case. How would the testsuite react if >> that attribute was cleared there? Is your patch still needed if >> gfc_expr_attr is fixed? > > You may be correct that something can be done elsewhere. > I do note that a function result can be allocatable > (within the funciton body). The issue only arises when > argument association is done, which is done where Harald > and I have the patch. Do we know that the function will > be an actual argument associated with an allocatable > dummy argument when gfc_expr_attr is invoked? > No, there is no context information in gfc_expr_attr, but the result should not be dependent on context anyway. You are probably right that the impact of this bug is limited to the case of argument association, not as broad as I thought. Yet we should not keep gfc_expr_attr returning an allocatable attribute for function expressions in any case.