From patchwork Sat Oct 16 18:48:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 46303 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DBE8385781A for ; Sat, 16 Oct 2021 18:48:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 8D23B3858D28; Sat, 16 Oct 2021 18:48:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D23B3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: v2rg0iHOvYHxp+SwzzaIOc7pYXkFWKuTRp05CD5/cpVMK04hn5pah2kRnuQJe6nGuQarNF8i0T wwTx5e185ktNjrDufBckYs21/Fm6PmkZYIe31i2ZhlIrXi6BTdoVX/OqTqfno+GLfn+aZCmdrZ PoUtRPhMIrWsrFLhBuAya5g10/0hiM5GyOg10dtHJ4d5Q4HsQq+VRB3RIKHPSFU5ml7R8cpMCV gtoh7pBqAxAHgNp9YuzOnMqfvOh2Xrf8uUtSZr2cxS+mg606wLDdaMzrOiK4qpICZlPRX+e3B7 664j+0wLQpGtFzxJXlge3SFL X-IronPort-AV: E=Sophos;i="5.85,378,1624348800"; d="diff'?scan'208";a="67290604" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 16 Oct 2021 10:48:07 -0800 IronPort-SDR: D/4XPNZgkhAszy87ST77U0SBxyhZrpYAEvluGffU9haK5blgkPIyb9QImuZiFEqQgpzy15ww0S Lm5BzNbA4YdDbBc0eCLq74tVQzYvIUS09CuSfTSWSIC+nKwCe+mQeZhIJnFIt4LI0hZ+WgOQDZ iizWXE/HkulnO8GKk/T4cFOBbb01BEW2tISr9aXMmGcVYdqmVStJpo6UzBAVjddsuCTy0t6hFR LtXJRUXaf8Ragz4niFR2FNxm9EeJn4+TW3Npin49BARGjJZp0fzrM5dJ4QHtBAW0ZA4+H33jU+ A70= Message-ID: Date: Sat, 16 Oct 2021 20:48:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: [Patch] (was: Re: [r12-4457 Regression] FAIL: gfortran.dg/deferred_type_param_6.f90 -Os execution test on Linux/x86_64) Content-Language: en-US To: Jan Hubicka , sunil.k.pandey , fortran References: <20211016161130.731AF286470F@gskx-2.sc.intel.com> <20211016182354.GE64164@kam.mff.cuni.cz> From: Tobias Burnus In-Reply-To: <20211016182354.GE64164@kam.mff.cuni.cz> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gcc-patches@gcc.gnu.org, gcc-regression@gcc.gnu.org, tobias@codesourcery.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi Honza, On 16.10.21 20:23, Jan Hubicka via Gcc-patches wrote: >> FAIL: gfortran.dg/deferred_type_param_6.f90 -O1 execution test >> FAIL: gfortran.dg/deferred_type_param_6.f90 -Os execution test > Sorry for the breakage. This time it seems like bug in Fortran FE > which was previously latent: > > __attribute__((fn spec (". . R "))) > void subfunc (character(kind=1)[1:..__result] * & __result, integer(kind=8) * .__result) ... Fortran has for a long time 'character(len=5), allocatable" or "character(len=*)". In the first case, the "5" can be ignored as both caller and callee know the length. In the second case, the length is determined by the argument, but it cannot be changed. Since a not-that-short while, 'len=:' together with allocatable/pointer is supported. In the latter case, the value can be change when the array association/allocation is changed. I attached a patch, which was not tested. I am not quite sure whether the pointer address can actually escape or not - I think cannot but I played safe. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 Fortran: Fix fn spec for character-returning functions gcc/fortran/ChangeLog * trans-types.c (create_fn_spec): For character-returning functions, set the hidden string-length argument to 'R' only when the "len=:", i.e. deferred length which goes alongside with allocatable/pointer. diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 220976babb8..637d2c71d01 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -3008,7 +3008,14 @@ create_fn_spec (gfc_symbol *sym, tree fntype) } if (sym->ts.type == BT_CHARACTER) { - spec[spec_len++] = 'R'; + if (!sym->ts.u.cl->length + && ((sym->attr.allocatable && sym->attr.target) + || sym->attr.pointer)) + spec[spec_len++] = '.'; + if (!sym->ts.u.cl->length && sym->attr.allocatable) + spec[spec_len++] = 'w'; + else + spec[spec_len++] = 'R'; spec[spec_len++] = ' '; } }