From patchwork Thu Nov 1 19:13:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 992062 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-488842-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sIliNFT4"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="HK92rWRD"; 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 42mFHC3HcyzB4Ww for ; Fri, 2 Nov 2018 06:13:41 +1100 (AEDT) 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=BVrqPaIuqbGDTdXYatBVhCLmnZaNAicNDWTHu+u9ThpbJem9LL bSg7YkBg4nOtgUgGFEln4MV6Zc0JqB9aBmNVOri31LQLdcDqXZmGHOKXBNZQHorC HprnGCgbEppisr4c/wi4k5tu8sJ6DfZkroZT8PPeg1zrsXHjeG93T7rao= 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=oiXmxr+zlg0WJu2dFfTiLqRtTJE=; b=sIliNFT4c0ZdAnrn+avn WXJCrX20fjsZScICdvCqe6d/5a6Zdzs3CwnHrQpWVAMaNN68rFzbtjgSSSRJahEr oJysnxOLHOgrIxXxFk/mlbUxGGi3Fv2EjkyJ3iA/tV+cMewb+sovd7Y0TySjKk98 D5jkHJjh2MRf2acdmVILOcM= Received: (qmail 76068 invoked by alias); 1 Nov 2018 19:13:34 -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 74967 invoked by uid 89); 1 Nov 2018 19:13:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=H*M:a813, H*MI:a813 X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Nov 2018 19:13:32 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id DD97F131A8; Thu, 1 Nov 2018 20:13:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1541099609; bh=5Qf2xLk9miqQ+WtQNaJJKcQ7DPerrdDEAXehIkuCxfE=; h=To:From:Subject:Message-ID:Date:From; b=HK92rWRDJXrYUeVj8uLS276GZAVqhe5CeUWbO7UK+RxksEGNr5D4AC61rAZ50Y3YA DJwMx3yltf9+AdIetRRw/GJwjsevUFUFCuU/9A3y0U0GHmcp5zC7hVjwCNDG9CMd9S Y38dZVcaghe6HTvQbRlq10O3S7RiRPd7iVXJp0PhHratggR0zXt+a9q8RRANuHOWYt H2aBGxcpwoQsqs5/6e+U3QewIVDVJlrfNBBXahVnvhbb5JSfE99YkUFObgaIIJjz11 r40/PORbGgAWt4+Xk+WBzLEt3frgS9sptjDeVu+3TWXLvU5O3pehrxQ6MZTbmHBwff lpwlig6pgBxQQ== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id DAB6211EE3; Thu, 1 Nov 2018 20:13:29 +0100 (CET) Received: from [78.35.133.178] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5bdb5059-01b0-7f0000012729-7f000001b210-1 for ; Thu, 01 Nov 2018 20:13:29 +0100 Received: from [192.168.178.68] (xdsl-78-35-133-178.nc.de [78.35.133.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Thu, 1 Nov 2018 20:13:27 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fux PR 87782 Message-ID: <9ec89e87-8aa8-1643-a813-a8fb1dff3010@netcologne.de> Date: Thu, 1 Nov 2018 20:13:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Hello world, the attached patch fixes the PR by not trying to determine the length of the base symbol when there is a substring with a length which is not constant. This might make the length of temporary strings generated by the front end optimization pass shorter, while inserting an additional call to determine length of the substring. No test case because the failure was only exposed by an instrumented compiler. Regression-tested. OK for trunk? Regards Thomas 2018-11-01 Thomas Koenig PR fortran/87782 * frontend-passes.c (constant_string_length): If there is a substring with a length which cannot be reduced to a constant, return NULL. Index: frontend-passes.c =================================================================== --- frontend-passes.c (Revision 265722) +++ frontend-passes.c (Arbeitskopie) @@ -638,23 +638,27 @@ constant_string_length (gfc_expr *e) return gfc_copy_expr(length); } - /* Return length of substring, if constant. */ + /* See if there is a substring. If it has a constant length, return + that and NULL otherwise. */ for (ref = e->ref; ref; ref = ref->next) { - if (ref->type == REF_SUBSTRING - && gfc_dep_difference (ref->u.ss.end, ref->u.ss.start, &value)) + if (ref->type == REF_SUBSTRING) { - res = gfc_get_constant_expr (BT_INTEGER, gfc_charlen_int_kind, - &e->where); + if (gfc_dep_difference (ref->u.ss.end, ref->u.ss.start, &value)) + { + res = gfc_get_constant_expr (BT_INTEGER, gfc_charlen_int_kind, + &e->where); - mpz_add_ui (res->value.integer, value, 1); - mpz_clear (value); - return res; + mpz_add_ui (res->value.integer, value, 1); + mpz_clear (value); + return res; + } + else + return NULL; } } /* Return length of char symbol, if constant. */ - if (e->symtree && e->symtree->n.sym->ts.u.cl && e->symtree->n.sym->ts.u.cl->length && e->symtree->n.sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)