From patchwork Sun Mar 18 22:23:37 2018 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: 887488 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-474915-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="wnu2I3Rb"; 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 404DHq5TMbz9sTm for ; Mon, 19 Mar 2018 09:23:50 +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=ashYCP37BpdGScYHtOEj9YQSbCfFbUuS/2zgCYwtprocNEwC/+ FmCBdgfzXI4ocb/OVfOS1LQ9pDm7gWVFwS6C18PF7uuWsnOYlYfKZuO8oHcoOp6d FVbWcH7G86djxswnlbB1iBtWVZH66NgRVVi+GBWt42SQjXqgFY+8NhmhU= 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=DM5qIVogmXlSksHL6boQ4Qq1Zck=; b=wnu2I3RbSUco204F7qHg hsbOjI7EEfjsL15jq+hAn78yrn4vd2lcUHnVzyC2ayv1NxzcZxddzPaZHEIhe9qI mPbRG6rJoCZrQBn+9yqSk/ml2Kut+ptJCdxZWePkCRor9twVtmnZmCTxT6es3thq P0QpzIp5JxAMrNaqERoTopY= Received: (qmail 41977 invoked by alias); 18 Mar 2018 22:23:43 -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 41960 invoked by uid 89); 18 Mar 2018 22:23:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mo4-p05-ob.smtp.rzone.de Received: from mo4-p05-ob.smtp.rzone.de (HELO mo4-p05-ob.smtp.rzone.de) (81.169.146.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 18 Mar 2018 22:23:40 +0000 X-RZG-CLASS-ID: mo05 X-RZG-AUTH: :OGckYUunfvGNVUL0FlRnC4eRM+bOwx0tUtYTrJ/xeZX+ZVZvrbiROUdnM26VdEk= Received: from [192.168.178.68] (xdsl-78-35-138-60.netcologne.de [78.35.138.60]) by smtp.strato.de (RZmta 42.18 DYNA|AUTH) with ESMTPSA id e07842u2IMNbM0o (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); Sun, 18 Mar 2018 23:23:37 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: =?utf-8?q?Thomas_K=C3=B6nig?= Subject: [patch, fortran] Fix type conversion in large array constructors with iterators Message-ID: <8d5c9fb1-5779-6871-5a80-18996dfd6d1b@tkoenig.net> Date: Sun, 18 Mar 2018 23:23:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Hello world, the attached patch fixes the bug that Steve found; the patch itself simply makes sure to copy a constructor instead of only the value of the constructor when converting types. Regressoin-tested. OK for trunk? Maybe this is also a candidate for gcc-7, because of the silent wrong-code issue. Regards Thomas 2018-03-18 Thomas Koenig PR fortran/84931 * simplify.c (gfc_convert_constant): Correctly handle iterators for type conversion. 2018-03-18 Thomas Koenig PR fortran/84931 * gfortran.dg/array_constructor_52.f90: New test. Index: simplify.c =================================================================== --- simplify.c (Revision 258501) +++ simplify.c (Arbeitskopie) @@ -8016,26 +8016,32 @@ gfc_convert_constant (gfc_expr *e, bt type, int ki { gfc_expr *tmp; if (c->iterator == NULL) - tmp = f (c->expr, kind); + { + tmp = f (c->expr, kind); + if (tmp == NULL) + { + gfc_free_expr (result); + return NULL; + } + + gfc_constructor_append_expr (&result->value.constructor, + tmp, &c->where); + } else { + gfc_constructor *n; g = gfc_convert_constant (c->expr, type, kind); - if (g == &gfc_bad_expr) + if (g == NULL || g == &gfc_bad_expr) { gfc_free_expr (result); return g; } - tmp = g; + n = gfc_constructor_get (); + n->expr = g; + n->iterator = gfc_copy_iterator (c->iterator); + n->where = c->where; + gfc_constructor_append (&result->value.constructor, n); } - - if (tmp == NULL) - { - gfc_free_expr (result); - return NULL; - } - - gfc_constructor_append_expr (&result->value.constructor, - tmp, &c->where); } break;