From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125054 invoked by alias); 1 Apr 2018 13:52:25 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@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, 01 Apr 2018 13:52:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------C69A7950BF043FEDD872005A" X-SW-Source: 2018-04/txt/msg00000.txt.bz2 This is a multi-part message in MIME format. --------------C69A7950BF043FEDD872005A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 545 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. --------------C69A7950BF043FEDD872005A Content-Type: text/x-patch; name="p2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="p2.diff" Content-length: 1410 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 --------------C69A7950BF043FEDD872005A Content-Type: text/x-fortran; name="array_simplify_2.f90" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="array_simplify_2.f90" Content-length: 210 ! { dg-do run } ! PR 85102 - this used to ICE ! Original test case by Gerhard Steinmetz program p integer, parameter :: a((1+2)) = 1 integer, parameter :: b = dot_product(a, a) if (b /= 3) stop 1 end --------------C69A7950BF043FEDD872005A--