From patchwork Sun May 5 14:05:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1095445 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-500117-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="FEO00EIQ"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="IEBgbdLR"; 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 44xnhK15lWz9s3l for ; Mon, 6 May 2019 00:05:34 +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=s2zFem0ZgDgU+iH9VNuplCiGB2Lb1AyKVSDswIWJE8As79RudY x4o1gl94pTvV57Z4TL198wbDL3KikuwYO8YEg2GrU/ojYWAFdceNmaCpa6MhDAxp DnOqeOweNIMFE3pXvSKRZe9+V6XtqsXMnC4MRSkZlyuuf8NmcujJ6QWqg= 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=V2GqO8+ZCmrRqdpoSzTnRcziISQ=; b=FEO00EIQkUqNo3pXRm1Q UFpme9GTnoX/R43AMw9v7XCOb+j8K9wgQsKt4GmL2y5BXtasvDdwscMIzpwPVOAJ LLofePN5SHkx/w/9YIU0wvtcwfmawVN3dVq4Ew0qn6/MiMSMzNgL2TfQbdlQpONx jYiTkGpKJfxwIbkVwnAeNK4= Received: (qmail 93280 invoked by alias); 5 May 2019 14:05:27 -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 93265 invoked by uid 89); 5 May 2019 14:05:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=tstype, Arbeitskopie, ts.type, H*Ad:U*tkoenig X-HELO: cc-smtpout3.netcologne.de Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 May 2019 14:05:25 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 4A77412637; Sun, 5 May 2019 16:05:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1557065119; bh=/woYVJQYmI3iEkVmTVKT9zuqE/NMjcpS6jSAvFECk7o=; h=To:From:Subject:Message-ID:Date:From; b=IEBgbdLRJTtCUNgSQUZxkE5LjlJ5jEplz47AhywaTwraEVo557/XUjCD+UJ90RPPD WzTxlVwRzW7AUb29jc/SFxOQPxjg8sAsZFeYzSYvyQAo9SpWz1YL6mo2XbKY1EAsN1 Kwx5LGVji5YRbvDQCFK6P9zKTPFEAKfIjvnFTueF+trLst8EoUktrPOGAhnuz8NIN5 yuxYHf5RWugU4xsQJTFecyuvPQOQCpXDo3AnQf7XtNryRQauZmz+FHt78w9yb3LN07 l4Ullm0n4i0qqPywMiEdlN329FrC57d0blVcL7+U/8DT3nKHuMnKcAygpEhkOCfs4G SpBhf3ChMLMkg== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 3D25511EC9; Sun, 5 May 2019 16:05:19 +0200 (CEST) Received: from [2001:4dd7:ac4:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5cceed9f-0155-7f0000012729-7f000001a6bc-1 for ; Sun, 05 May 2019 16:05:19 +0200 Received: from [IPv6:2001:4dd7:ac4:0:7285:c2ff:fe6c:992d] (2001-4dd7-ac4-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:ac4:0:7285:c2ff:fe6c:992d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sun, 5 May 2019 16:05:15 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, committed] Fix gcc-7 regression in front-end optimization Message-ID: <867dff12-4f5f-0256-715b-08e74fb8dce5@netcologne.de> Date: Sun, 5 May 2019 16:05:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Hello world, I have just committed the attached patch as obvious after regresson-testing - it fixed a rare beast, a gcc 7.4-only regression. I have also committed the test case to trunk, to make sure that this does not re-break. No real need to commit to the other branches, I think. Regards Thomas 2019-05-05 Thomas Koenig PR fortran/90344 * frontend-passes.c (create_var): Bring into sync with gcc 8. 2019-05-05 Thomas Koenig PR fortran/90344 * gfortran.dg/pr90344.f90: New test. Index: frontend-passes.c =================================================================== --- frontend-passes.c (Revision 270881) +++ frontend-passes.c (Arbeitskopie) @@ -701,6 +701,11 @@ create_var (gfc_expr * e, const char *vname) if (e->expr_type == EXPR_CONSTANT || is_fe_temp (e)) return gfc_copy_expr (e); + /* Creation of an array of unknown size requires realloc on assignment. + If that is not possible, just return NULL. */ + if (flag_realloc_lhs == 0 && e->rank > 0 && e->shape == NULL) + return NULL; + ns = insert_block (); if (vname) @@ -748,7 +753,7 @@ create_var (gfc_expr * e, const char *vname) } deferred = 0; - if (e->ts.type == BT_CHARACTER && e->rank == 0) + if (e->ts.type == BT_CHARACTER) { gfc_expr *length; @@ -759,6 +764,8 @@ create_var (gfc_expr * e, const char *vname) else { symbol->attr.allocatable = 1; + symbol->ts.u.cl->length = NULL; + symbol->ts.deferred = 1; deferred = 1; } } @@ -771,7 +778,7 @@ create_var (gfc_expr * e, const char *vname) result = gfc_get_expr (); result->expr_type = EXPR_VARIABLE; - result->ts = e->ts; + result->ts = symbol->ts; result->ts.deferred = deferred; result->rank = e->rank; result->shape = gfc_copy_shape (e->shape, e->rank);