From patchwork Sun Apr 1 13:52:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 893993 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-475676-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none 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="Vxzp0cOH"; 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 40DcHS4X9Lz9s1B for ; Sun, 1 Apr 2018 23:52:33 +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=ZmX28CI4hv2dt+t904GFPs6eAwRoZMUq11y/n2wOPTgbrBnBJl MxodXc+KpcG29RvhBYwbXONaQThOPQUQpHybvneSHiSWEOW+PRTM2b5dTt3/WX7T al3OLgYIP/PuMDLIdxT249rYr4KWmXKFjtJ7kxCsph0vx90/e/TpnkOK4= 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=g0pQz77X5wN+/oMO3ou8tAbZys0=; b=Vxzp0cOHNDH1FpUsWbed qBXBt0lQ4vzwgMnAX82CD0/u+JwIVsHYOX0agNFDY54MdjJ4BombJktL/kmS345M vimjN2c7H91MidhcCBE4JlUci8Ip4KAofoe4BvuSVdrAZPxV4M8EcL4GDfBxy7sv XpRJLKOi6Ybt+EF99HqhigI= Received: (qmail 125055 invoked by alias); 1 Apr 2018 13:52:25 -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 125018 invoked by uid 89); 1 Apr 2018 13:52:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No 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, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=filled, Hx-languages-length:2059 X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Apr 2018 13:52:21 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id 4222C12BCB; Sun, 1 Apr 2018 15:52:17 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id 3401111DDF; Sun, 1 Apr 2018 15:52:17 +0200 (CEST) Received: from [78.35.131.140] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 5ac0e411-029d-7f0000012729-7f000001cbbc-1 for ; Sun, 01 Apr 2018 15:52:17 +0200 Received: from [192.168.178.68] (xdsl-78-35-131-140.netcologne.de [78.35.131.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Sun, 1 Apr 2018 15:52:15 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 85102 Message-ID: <93e78b0a-8086-d67b-4c6e-08de258f7af7@netcologne.de> Date: Sun, 1 Apr 2018 15:52:15 +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, this is a minimal-invasive patch to fix the case where array specs starting with a parenthesis were not handled correctly. Regression-tested. OK for trunk? Regards Thomas 2018-04-01 Thomas Koenig PR fortran/85102 * array.c (strip_parens): New function. (match_array_element_spec): Use it to strip away parentheses from array bounds. 2018-04-01 Thomas Koenig PR fortran/85102 * gfortran.dg/array_simplify_2.f90: New test. Index: array.c =================================================================== --- array.c (revision 258973) +++ array.c (working copy) @@ -408,7 +408,23 @@ gfc_resolve_array_spec (gfc_array_spec *as, int ch return true; } +/* Strip away any parentheses around an expression. The argument is + assumed to be non-NULL. */ +static void +strip_parens (gfc_expr *e) +{ + gfc_expr *r; + + r = e; + + while (r->expr_type == EXPR_OP && r->value.op.op == INTRINSIC_PARENTHESES) + r = r->value.op.op1; + + if (r != e) + gfc_replace_expr (e, gfc_copy_expr (r)); +} + /* Match a single array element specification. The return values as well as the upper and lower bounds of the array spec are filled in according to what we see on the input. The caller makes sure @@ -457,6 +473,7 @@ match_array_element_spec (gfc_array_spec *as) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) return AS_UNKNOWN; + strip_parens (*upper); if (((*upper)->expr_type == EXPR_CONSTANT && (*upper)->ts.type != BT_INTEGER) || ((*upper)->expr_type == EXPR_FUNCTION @@ -489,6 +506,7 @@ match_array_element_spec (gfc_array_spec *as) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) return AS_UNKNOWN; + strip_parens (*upper); if (((*upper)->expr_type == EXPR_CONSTANT && (*upper)->ts.type != BT_INTEGER) || ((*upper)->expr_type == EXPR_FUNCTION