From patchwork Tue Oct 19 14:49:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 46401 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 0D18D3858010 for ; Tue, 19 Oct 2021 14:49:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id E365E3858423; Tue, 19 Oct 2021 14:49:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E365E3858423 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: CdPXYy5wWbZ3V4vdQ2AkKNKg4VzpU/ape2nv2QAjFgnF2JZqjXsVAHqt/TjyV4NJ0skPYySe2p gJADgatmHoMPO+9EpAWoJkr4LoVHPjxddEtgdK1SvO8B+8c/rZJwVEgoy6ybS79BT7dvQnFjuX QUR4xMlcuWJ7bYmVRhnE6nteuqQtQO9qupC5tTHPMYHoeVNmdR2e52Scg2GJhjFCyCBh5LhGla N9Z+K7+oDVLsDeJUTfhd0mEnlhZ+2LqVREoHTY47uuKg0gvZM+pYxckrwjoQpXxW/HdqXiOqjB xDLQseHZIN7FGELizCVMdlJR X-IronPort-AV: E=Sophos;i="5.87,164,1631606400"; d="diff'?scan'208";a="67365699" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 19 Oct 2021 06:49:09 -0800 IronPort-SDR: JnTevmgcyulvVI5haRgrq3sm6BSSGfzK6PGSTfftgM8j+o+WxO4UrcPWgHaMN3os7D8aGRJ0/c PetD93ztTFqTjoQ+Qs3KOaDbqmiHxl2ATf4TJnImKFBdtrQh1NriZs45xKLc2N1/lHY11s5z9Y 9Nzen4OiIffZaTy8Cx9zW8jR05DDx12Jw8J4MWeJAjoYszC6AhO91IQnq/7rNzB9DW+tvTKXPn 3KXmVInuprJG6kRn4FluRwU1DfaM3khO3S8pX3YiFdTEg6jCI8HN0sQb1JmnvGNTOTSptnNhYJ tMw= Message-ID: Date: Tue, 19 Oct 2021 16:49:02 +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, committed] Fortran: Fix 'fn spec' for deferred character length (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 , Tobias Burnus References: <20211016161130.731AF286470F@gskx-2.sc.intel.com> <20211016182354.GE64164@kam.mff.cuni.cz> <20211016185437.GB23986@kam.mff.cuni.cz> From: Tobias Burnus In-Reply-To: <20211016185437.GB23986@kam.mff.cuni.cz> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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-regression@gcc.gnu.org, gcc-patches@gcc.gnu.org, "sunil.k.pandey" , fortran Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On 16.10.21 20:54, Jan Hubicka wrote: > I wrote: >> 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. >> ... >> + 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'; > Also escaping is quite important bit of information so it would be > good to figure out if it really can escape rather than playing safe. The pointer to the string length variable itself does not escape, only its integer string value: subroutine foo(x) character(len=:), pointer :: x character(len=:), pointer :: y y => x has in the dump: .y = *_x; y = (character(kind=1)[1:.y] *) *x; Thus, 'w' can always be used. Committed as obvious as r12-4511-gff0eec94e87dfb7dc387f120ca5ade2707aecf50 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 commit ff0eec94e87dfb7dc387f120ca5ade2707aecf50 Author: Tobias Burnus Date: Tue Oct 19 16:38:56 2021 +0200 Fortran: Fix 'fn spec' for deferred character length Shows now up with gfortran.dg/deferred_type_param_6.f90 due to more ME optimizations, causing fails without this commit. gcc/fortran/ChangeLog: * trans-types.c (create_fn_spec): For allocatable/pointer character(len=:), use 'w' not 'R' as fn spec for the length dummy argument. --- gcc/fortran/trans-types.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 50fceebc941..42778067dbe 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -3014,7 +3014,11 @@ 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.pointer)) + spec[spec_len++] = 'w'; + else + spec[spec_len++] = 'R'; spec[spec_len++] = ' '; } }