From patchwork Mon Apr 2 12:05:29 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: 894164 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-475695-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="Dh10C8Pw"; 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 40F9sg63Q3z9s15 for ; Mon, 2 Apr 2018 22:05:42 +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=MY6IWUpBh1oEV0J65o0FuLW0Ou+vDRnRcCGb6QHVmOxFydDcDc lSfGuU4HOaATigGGc0w20vjugiEGTcYfihh3QdRamwkL6MrBsF9Giq4Osm94zgci HVP9h8zpf7+vN1JsVmfmRrxUgE3ShwuVuxHjyfwf6+08wSclfzqcdslOo= 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=k7EZq5n4tl0/9cOdKaZ1HCcJAw4=; b=Dh10C8Pwc76ol1sOPjgt E+aLTqaJ+ojBPHRFE+PVrDL2pFv2AhFkK46pGmxNegOfJkSE149rATnozUtyRN60 ufn4Ft2/H2MaXDEbgdO6g7V7N59+npQMAkAUHz4cTaFYHz/TTCmpmgobYGfovyZr cuKKRZM8tpyumuP5rj1gTtg= Received: (qmail 51768 invoked by alias); 2 Apr 2018 12:05:35 -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 51742 invoked by uid 89); 2 Apr 2018 12:05:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.220) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Apr 2018 12:05:32 +0000 X-RZG-AUTH: :OGckYUunfvGNVUL0FlRnC4eRM+bOwx0tUtYTrJ/xeZX+ZVZvrbiROUdnOm6ScCRz X-RZG-CLASS-ID: mo00 Received: from [192.168.178.68] (xdsl-78-35-131-140.netcologne.de [78.35.131.140]) by smtp.strato.de (RZmta 43.1 DYNA|AUTH) with ESMTPSA id V073b6u32C5TBY4 (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); Mon, 2 Apr 2018 14:05:29 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches , Dominique Dhumieres From: =?utf-8?q?Thomas_K=C3=B6nig?= Subject: [patch, fortran] Fix PR 85102, take 2 Message-ID: Date: Mon, 2 Apr 2018 14:05:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Hello world, here is the second version of the fix for PR 85102. This is a much more general approach, which actually uses simplification (while avoiding some "interesting" regressions when resolving, or simplifying, too soon...) Thanks to Dominique for the hint about the problem with my first patch. Regression-tested. OK for trunk? Regards Thomas 2018-04-02 Thomas Koenig PR fortran/85102 * decl.c (variable_decl): If upper or lower bounds simplify to a constant, use that. 2018-04-02 Thomas Koenig PR fortran/85102 * gfortran.dg/array_simplify_2.f90: New test. Index: decl.c =================================================================== --- decl.c (revision 258845) +++ decl.c (working copy) @@ -2424,6 +2424,29 @@ variable_decl (int elem) goto cleanup; } } + if (as->type == AS_EXPLICIT) + { + for (int i = 0; i < as->rank; i++) + { + gfc_expr *e, *n; + e = as->lower[i]; + if (e->expr_type != EXPR_CONSTANT) + { + n = gfc_copy_expr (e); + gfc_simplify_expr (n, 1); + if (n->expr_type == EXPR_CONSTANT) + gfc_replace_expr (e, n); + } + e = as->upper[i]; + if (e->expr_type != EXPR_CONSTANT) + { + n = gfc_copy_expr (e); + gfc_simplify_expr (n, 1); + if (n->expr_type == EXPR_CONSTANT) + gfc_replace_expr (e, n); + } + } + } } char_len = NULL;