From patchwork Tue Aug 13 12:59:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_K=C3=B6nig?= X-Patchwork-Id: 1146336 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-506811-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tkoenig.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VYSeVK5Q"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=tkoenig.net header.i=@tkoenig.net header.b="L/zbl2kz"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 467CVX2MZSz9sDQ for ; Tue, 13 Aug 2019 23:00:04 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=M5nq4dHemi9LFlbjmafIQrSchnpt4WcZ7ZnRSStYBu8CMcnGjS Fx3Sfszo4+BB/6rVJg/7/OUGYK4z0EAfi9A6YK6qROmUhKRFAgwbw3P6au0mRIK/ b7LdIFSMF/clZIsHnNKl5leFTVFX0DLh3LHZv4gPlYPqVrT8WVyW/1xnY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=Bd4cBAFMgL7J+fnruWwSimBaQeg=; b=VYSeVK5QhAAusLfIre5M iBtE2EYg8acwrFy3glDC7jzFv8zL6Q/gM9O61tYTappRkqFaDbSByIITv/sgHoNp jZdC1aU/V/rfyqVf/5NB4upM4xc8MmeuXDJfY9xWnhuqjE9ca+R4mo+Y99G6w9FN f88MJ0GNwvo7busTf4sZnf8= Received: (qmail 101127 invoked by alias); 13 Aug 2019 12:59:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 101106 invoked by uid 89); 13 Aug 2019 12:59:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*r:AUTH X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (85.215.255.25) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Aug 2019 12:59:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1565701186; s=strato-dkim-0002; d=tkoenig.net; h=Date:Message-ID:Subject:From:To:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=cgICg3uxFrUDxUaeCaiB6fN8SvHSA9gH/IaoZEK2j7E=; b=L/zbl2kzfm8x/tcVwQE/kHUTMSyi5ogi5FtX9Tpr2QlFw6WBzQQ4JrtNvoPjtu9h5U 88bLwZTCeVOLy6x5jxWSbrGlIqhWjiRzkb7hlibzghV0lyEy9lMNztRsbtVMMpFGwoK8 yhlVjWdXd6aF7o5ZovLbHRDmodCoX/T63njLwP6YmwK3HwLxrRGCfmvZ22chlc9rxHzi o8a99+NRlf4s+7mc+P1NuBAjekob4sMDLSXrXeQm1lZ81353UnTSMAA+ITfFy1xmlP4+ ZQiSW8UOhBlCXkHzjSd+5R2AM8u0kGk+KSYBaQfEk5LgmlqTX4vKa/+jXOvokFwXWCcD MIow== Received: from [IPv6:2001:4dd6:e4c:0:7285:c2ff:fe6c:992d] by smtp.strato.de (RZmta 44.26.1 AUTH) with ESMTPSA id m07349v7DCxj0FG (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Tue, 13 Aug 2019 14:59:45 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: =?utf-8?q?Thomas_K=C3=B6nig?= Subject: [patch, fortran] Fix PR 90561 Message-ID: <8cc87fd5-ca82-ef10-6120-7d3e5a23ae8c@tkoenig.net> Date: Tue, 13 Aug 2019 14:59:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Hello world, this patch fixes a 9/10 regression by placing the variable used to hold a string length at function scope. I chose to implement this version of gfc_evaluate_now as a separate function because I have a sneaking suspicion this may not be the last time we are going to encounter something like that - better have the function there for future use. Regression-tested. OK for trunk and gcc-9? Regards Thomas Index: trans.h =================================================================== --- trans.h (Revision 274370) +++ trans.h (Arbeitskopie) @@ -507,6 +507,7 @@ void gfc_conv_label_variable (gfc_se * se, gfc_exp /* If the value is not constant, Create a temporary and copy the value. */ tree gfc_evaluate_now_loc (location_t, tree, stmtblock_t *); tree gfc_evaluate_now (tree, stmtblock_t *); +tree gfc_evaluate_now_function_scope (tree, stmtblock_t *); /* Find the appropriate variant of a math intrinsic. */ tree gfc_builtin_decl_for_float_kind (enum built_in_function, int); Index: trans.c =================================================================== --- trans.c (Revision 274370) +++ trans.c (Arbeitskopie) @@ -118,7 +118,20 @@ gfc_evaluate_now (tree expr, stmtblock_t * pblock) return gfc_evaluate_now_loc (input_location, expr, pblock); } +/* Like gfc_evaluate_now, but add the created variable to the + function scope. */ +tree +gfc_evaluate_now_function_scope (tree expr, stmtblock_t * pblock) +{ + tree var; + var = gfc_create_var_np (TREE_TYPE (expr), NULL); + gfc_add_decl_to_function (var); + gfc_add_modify (pblock, var, expr); + + return var; +} + /* Build a MODIFY_EXPR node and add it to a given statement block PBLOCK. A MODIFY_EXPR is an assignment: LHS <- RHS. */ Index: trans-expr.c =================================================================== --- trans-expr.c (Revision 274370) +++ trans-expr.c (Arbeitskopie) @@ -10796,7 +10796,8 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr if (expr1->ts.deferred && gfc_expr_attr (expr1).allocatable && gfc_check_dependency (expr1, expr2, true)) - rse.string_length = gfc_evaluate_now (rse.string_length, &rse.pre); + rse.string_length = + gfc_evaluate_now_function_scope (rse.string_length, &rse.pre); string_length = rse.string_length; } else