From patchwork Sat Mar 9 12:44:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_K=C3=B6nig?= X-Patchwork-Id: 1053836 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-497606-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="V7F2xaMD"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=tkoenig.net header.i=@tkoenig.net header.b="iJkyncoF"; 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 44GkbR4SWDz9s70 for ; Sat, 9 Mar 2019 23:44:47 +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=WnWSiPD8ZQ3XQy1sNrVbkgYd8FsncvKWWXq5414CjqRQ6fqz8c jniqG4nPLkVdGe+9zp8R/wZUexEpZjeOGAyEH+Fjsgq0OB1i+9zi/H7GuNOmpRO7 MQe6v/cO0bmj8S+Ft0NZcUlc7BR1J1Yxxd+VFvbBQiZzv/tt1zTf+xF2s= 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=cZShNePX6D++A9J2CtZjFKB1EyE=; b=V7F2xaMDw8XYy0qJXPl0 NDiIHRZZMWzs7+Xim4DyjGOUrbG6STy/S8RWSUoLBjbCjNinSH1Mi81NDz1MhmLc uzfnb9St2hn7feYBBUpWqiZI0OHaLYMxjnNnLpI+8GpLdBrW6VP2mZv43DHbAv1C FxipELxM/Gkoj/G65HMxCEM= Received: (qmail 23009 invoked by alias); 9 Mar 2019 12:44:36 -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 22992 invoked by uid 89); 9 Mar 2019 12:44:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=tkoeniggccgnuorg, tkoenig@gcc.gnu.org, 71203, H*F:U*tk 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.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Mar 2019 12:44:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1552135471; 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=KkJlNKMTpmkK3C5YM3H2DOzeoO2YfIAjwpVhmc+yqlk=; b=iJkyncoFB9GH32OWMs7N2A22IMdlDAQvcp/4zrmhDO0NhuKVCbbvQKZlLXS7BWINGI qsq+V0dyEPOGjMqkeWFxFqt7rVp24upPh6hEcYvMX9GF2YI91Qy/cC5Tvw5+myI0Pkmt 2JqxyY8sbZaDbrNjf2tn3zb05gaT4XLkz+BeAEMvEhrhSIEtp5lmZuVKFbmrN05VTKVO NsAVL9DqgMM+J7AMHPN9qypELZKZ1E60/Dn4ziPYvBLO8hJFRDwGTtBtawYDw25QbmAJ +52uG23iWj7Zg/c/ZdirW2TzegiDQycRPXjMMqlWwvXVCPL8ouM3eh+6QcSCedIBJf+2 P81Q== Received: from [IPv6:2001:4dd7:fd2:0:7285:c2ff:fe6c:992d] by smtp.strato.de (RZmta 44.13 AUTH) with ESMTPSA id j0aa17v29CiUwfk (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); Sat, 9 Mar 2019 13:44:30 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: =?utf-8?q?Thomas_K=C3=B6nig?= Subject: [patch, fortran] Fix the rest of PR 71203 Message-ID: Date: Sat, 9 Mar 2019 13:44:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Hello world, the attached patch fixes the rest of PR 71203 (i.e. the non-character parts). I have checked in gdb that the shape set with this patch does indeed not create a memory leak. Regression-tested. OK for trunk? (This makes three patches that are currently awaiting review, the other two are https://gcc.gnu.org/ml/fortran/2019-03/msg00022.html and https://gcc.gnu.org/ml/fortran/2019-02/msg00241.html. I'd appreciate somebody looking at these, I think I am close to the limit of concurrent patches in my tree :-) Regards Thomas 2019-03-09 Thomas König PR fortran/71203 * decl.c (add_init_expr_to_sym): Add shape if init has none. Add assert that it has to be an EXPR_ARRAY in this case. 2019-03-09 Thomas König PR fortran/71203 * gfortran.dg/array_simplify_3.f90: New test case. Index: decl.c =================================================================== --- decl.c (Revision 269443) +++ decl.c (Arbeitskopie) @@ -1983,8 +1983,14 @@ add_init_expr_to_sym (const char *name, gfc_expr * return false; } - /* Shape should be present, we get an initialization expression. */ - gcc_assert (init->shape); + /* The shape may be NULL for EXPR_ARRAY, set it. */ + if (init->shape == NULL) + { + gcc_assert (init->expr_type == EXPR_ARRAY); + init->shape = gfc_get_shape (1); + if (!gfc_array_size (init, &init->shape[0])) + gfc_internal_error ("gfc_array_size failed"); + } for (dim = 0; dim < sym->as->rank; ++dim) {